-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Functions in default parameters should have separate scope #2584
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
Comments
We'll need to rename the inner |
i think we have a few options:
I think the least we can do, is when resolving names in initializes do them outside the function scope, so the above example would be an error assuming there is no global 'b' defined. |
Why this serious difference is not fixed such a long time? |
At least if you fix the type checking of this, Babel can be used to resolve transpile bug. |
This one still isn't fixed. Since the reported code is not complete, I'll re-post the correct one that can be used as a test case: // @target: es5
function f() {
return (function(a= () => typeof b === "undefined") {
var b = 1;
return a();
}());
}
console.log(f()) |
It's been 9 years, no one has sent a PR in that time, and compiling to ES5 at this point is pretty rare. Doesn't seem to merit more consideration. |
Expected:
true
Actual:
false
The text was updated successfully, but these errors were encountered: