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
Don't resolve shadowed arguments
variables from functions
#14036
Don't resolve shadowed arguments
variables from functions
#14036
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/50332/ |
packages/babel-traverse/test/fixtures/conversion/implicit-var-arguments/output.js
Outdated
Show resolved
Hide resolved
The fix should be inside the renamer. You can edit this code: babel/packages/babel-traverse/src/scope/lib/renamer.ts Lines 21 to 26 in 3908049
to also skip if |
Or even better, if it works, in babel/packages/babel-traverse/src/scope/index.ts Lines 1116 to 1144 in 3908049
If var arguments = [];
function f() {
return arguments;
} the |
@nicolo-ribaudo Okay, I got I will make the changes just as you described in the next commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
packages/babel-traverse/test/fixtures/conversion/implicit-var-arguments/exec.js
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,4 @@ | |||
{ | |||
"sourceType": "unambiguous", | |||
"presets": ["env"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Babel 8 tests are failing because you didn't specify any target here. Could you move this test in the arrow functions plugin, and enable the plugin instead of the preset?
Also, please specify "sourceType": "script"
since this is specific to loose mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I can do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the same as you said.
@@ -1,7 +1,7 @@ | |||
var _arguments2 = 1; | |||
|
|||
function fn() { | |||
var _arguments = _arguments2; | |||
var _arguments = arguments; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for self and others: this is correct, the test was previously broken — fn
should not see the outer arguments
, because it was not an arrow function in input.js
arguments
variables from functions
Function's implicit argument binding now won't fail because the
arguments
identifier in function will be renamed differently than thearguments
identifier in any another scope.