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
Disallow await as bound name in using declaration #15391
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53834/ |
a5a9380
to
097eb45
Compare
@@ -0,0 +1,3 @@ | |||
{ | |||
"sourceType": "script" |
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.
Can you also add a test in modules? It throws that await
is reserved in modules, right?
"type": "File", | ||
"start":0,"end":113,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":12,"column":1,"index":113}}, | ||
"errors": [ | ||
"SyntaxError: Can not use 'await' as identifier inside an async function. (2:8)", |
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.
Unrelated, but this error message is wrong (we are not in an async function, but at the top-level of a module).
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.
We don't differentiate between module top level and async function as long as [Await]
production parameter set. Maybe rephrase it as "Can not use 'await' as identifier inside an async context"?
This PR starts by simplifying let-as-name binding checking, but then I realize that the
using
declaration has already banned binding patterns, which greatly simplifies the await-checking. Anyway I am pleased that we get rid of a parameter from the hot pathcheckIdentifier
.