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
[Bug]: Parser throws when var declaration and function declaration in class static block #14257
Comments
Hey @overlookmotel! 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. |
The error is thrown from babel/packages/babel-parser/src/util/scope.js Line 152 in 76dd491
When Babel is parsing a static block, it will push a
I think we should handle that in babel/packages/babel-parser/src/util/scope.js Line 103 in 76dd491
Alternatively, we can enable |
@overlookmotel I'm assigning this to you since you selected "Would you like to work on a fix?". If you are not interested anymore just leave a comment! |
I would be happy to take on this issue @nicolo-ribaudo . |
@Yokubjon-J I'd be very happy if you did! I was going to, but I'm unfamiliar with the parser code base, so will probably take me a while. |
please assign me, @nicolo-ribaudo. i have started working on the issue. |
That might be a bug in our test runner; what does it say if you set the |
Thanks, it worked! I am back to the issue. |
@nicolo-ribaudo when i write tests inside already created folders, they execute normally. |
@Yokubjon-J Please run |
…claration in class static block babel#14257
…claration in class static block babel#14257
* solution to [Bug]: Parser throws when var declaration and function declaration in class static block #14257 * removed SCOPE_FUNCTION addition in statement.js (babel-parser) * Update packages/babel-parser/src/util/scope.js Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> * Undo unrelated changes * test case in new subdir * import typeof.js * import typeof.js * import typeof.js in babel-runtime * import correct typeof.js in corejs2 and 3 in esm * removed 2 unneeded tests from es2015 Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com> Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
@Yokubjon-J Just want to say thanks loads for fixing this. |
@overlookmotel thank you also for letting me have this bug (to fix)! |
💻
How are you using Babel?
Programmatic API (
babel.transform
,babel.parse
)Input code
REPL
Configuration file name
No response
Configuration
n/a
Current and expected behavior
I believe that the above code is legal. It happily runs in NodeJS.
Babel's parser throws an error
Identifier 'x' has already been declared
.This only applies within a class static block. The following parses correctly (when
sourceType: 'script'
):REPL
Environment
Possible solution
No response
Additional context
Happy to work on a PR. But could someone please point in right direction? I'm not at all familiar with the parser.
The text was updated successfully, but these errors were encountered: