-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix(es/parser): emit error if await used as ident in class static ini… #8450
Conversation
|
ef080ed
to
790f424
Compare
This case should be added. class Foo {
static {
function foo() {
var await = 'bar';
}
}
} |
Thanks for this, I've added it. |
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!
swc-bump:
- swc_ecma_parser
@@ -2407,6 +2407,19 @@ export default function waitUntil(callback, options = {}) { | |||
test_parser(src, Syntax::Es(Default::default()), |p| p.parse_expr()); | |||
} | |||
|
|||
#[test] | |||
#[should_panic(expected = "Expected ident")] |
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.
No. It should not panic. It's valid JavaScript.
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.
@magic-akari i didn't realise 😓
fixed it, but i'm not sure if the solution accounts for all corner cases...could you take a look?
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.
class Foo {
static {
var await = "bar"; // SyntaxError: Unexpected reserved word
function foo() {
var await = "bar"; // ok
class Bar {
static {
var await = "bar"; // SyntaxError: Unexpected reserved word
}
}
}
}
}
I recommend setting the variable in_static_block
to false
upon entering the function body.
Please note that I cannot guarantee that all scenarios have been considered.
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.
Fixed, your suggested solution seems much better to me.
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.
@magic-akari bump
e8b9b84
to
110d17b
Compare
…tializer
Description:
This PR fixes #8374
BREAKING CHANGE:
Related issue (if exists):
#8374