Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid useless ifelse check during fallback type conversion #232

Conversation

ExE-Boss
Copy link
Contributor

This makes it so that for fallback types (e.g. boolean and number), if it’s the last fallback type among overloads or in a union, then the conversion will no longer be duplicated in the if‑and‑else branches:

-} else if (typeof curArg === \\"boolean\\") {
-	{
-		let curArg = arguments[0];
-		curArg = conversions[\\"boolean\\"](curArg, {
-			context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\"
-		});
-		args.push(curArg);
-	}
 } else {
 	{
 		let curArg = arguments[0];
 		curArg = conversions[\\"boolean\\"](curArg, {
 			context: \\"Failed to execute 'overloadsObjectOrBoolean' on 'NoUselessIfElse': parameter 1\\"
 		});
 		args.push(curArg);
 	}
 }

Depends on:

@TimothyGu
Copy link
Member

I'd rather not do this, since it makes the code harder to maintain by diverging from the overload resolution algorithm in the spec.

@TimothyGu TimothyGu closed this Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants