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
transpiled rest param assumes Array is built-ins #11744
Comments
Hey @yortus! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite." |
Currently Babel output assumes the built-ins are not modified in a spec-incompliant way. In your case it is shadowed and |
The builtin is not modified, and there is nothing spec-incompliant in the sample code. This is simple shadowing by an ordinary variable in lexical scope. Babel is just making a faulty assumption here. The section added to Alternatively, since babel knows the variable names in the program being transpiled, it could issue an error here since the output would be invalid. Or even better, refer to builtins in a way that can't clash with local names. |
Bug Report
The transpiled code for rest params may have different semantics to the original code. The transpiled code injects a reference to
Array
, assuming it is the builtin array constructor. However if another identifier calledArray
is in scope, it will be referenced instead.Input Code
Current behavior
Running the transpiled code for this example throws
"TypeError: Array is not a constructor"
.Expected behavior
Running the transpiled code outputs
[1, 2, 3]
.Environment
The text was updated successfully, but these errors were encountered: