Skip to content
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

Merged
merged 3 commits into from Mar 25, 2021

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Dec 2, 2020

Q                       A
Fixed Issues? tc39/ecma262#2197
Tests Added + Pass? Yes
License MIT

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 check node.left.type and extra.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)

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories pkg: parser labels Dec 2, 2020
@@ -387,7 +387,7 @@ export type YieldExpression = NodeBase & {

export type AwaitExpression = NodeBase & {
type: "AwaitExpression",
argument: ?Expression,
argument: Expression,
Copy link
Contributor Author

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.

@babel-bot
Copy link
Collaborator

babel-bot commented Dec 2, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44668/

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 2, 2020

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:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@JLHwung JLHwung force-pushed the disallow-await-before-exponential branch from d1cf0c6 to cadadcc Compare December 3, 2020 15:43
@JLHwung JLHwung force-pushed the disallow-await-before-exponential branch from cadadcc to 7e186f0 Compare March 25, 2021 14:41
@JLHwung
Copy link
Contributor Author

JLHwung commented Mar 25, 2021

✔️

(After 3 months I have completely forgotten the context of this PR)

@JLHwung JLHwung merged commit 0067fd9 into babel:main Mar 25, 2021
@JLHwung JLHwung deleted the disallow-await-before-exponential branch March 25, 2021 15:20
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 25, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants