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 before exponential #12441
Disallow await before exponential #12441
Conversation
@@ -387,7 +387,7 @@ export type YieldExpression = NodeBase & { | |||
|
|||
export type AwaitExpression = NodeBase & { | |||
type: "AwaitExpression", | |||
argument: ?Expression, | |||
argument: Expression, |
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.
While yield
is a yield expression, await
is never valid and thus the argument
here can not be null
.
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44668/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 7e186f0:
|
d1cf0c6
to
cadadcc
Compare
cadadcc
to
7e186f0
Compare
✔️ (After 3 months I have completely forgotten the context of this PR) |
Babel does not throw for await before exponential:
async () => await -1 ** 1
, REPL,See here for the real diff.This PR forbids await expression when it is the
left
of an exponential expression. In the first commit we refactor current check so we don't have to checknode.left.type
andextra.parenthesized
, instead we check it when an AwaitExpression / UnaryExpression is parsed. Then we forbid exponential after an await is parsed.This approach is also implemented in V8 (here) and acorn (here)