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

ecmaVersion: 2022 allows top-level await in scripts and class field initializers #1048

Closed
mdjermanovic opened this issue Jun 22, 2021 · 2 comments

Comments

@mdjermanovic
Copy link

Acorn v8.4.0

7405bd1 enables the allowAwaitOutsideFunction option by default when ecmaVersion >= 2022. That was to support top-level await in ES2022, but it seems that the option allows more than it is allowed by the spec.

const acorn = require("acorn");

// doesn't throw, but it should?
acorn.parse("await foo();", { ecmaVersion: 2022, sourceType: "script" });

// doesn't throw, but it should?
acorn.parse("(class { x = await foo(); })", { ecmaVersion: 2022, sourceType: "module" });
@marijnh
Copy link
Member

marijnh commented Jun 23, 2021

Could you take a look through attached patch to see if it agrees with how you'd expect the library to behave?

marijnh added a commit that referenced this issue Jun 23, 2021
So that it can be used in computed properties in classes.

Makes the test262 suite run again.

Issue #1048
@mdjermanovic
Copy link
Author

Looks good to me, thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants