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

Should throw on async () => await 5 ** 6; #472

Closed
fisker opened this issue Mar 29, 2021 · 11 comments · Fixed by #492
Closed

Should throw on async () => await 5 ** 6; #472

fisker opened this issue Mar 29, 2021 · 11 comments · Fixed by #492

Comments

@fisker
Copy link
Contributor

fisker commented Mar 29, 2021

espree parse this as await (5 ** 6)

require('espree').parse('async () => await 5 ** 6', {ecmaVersion: 2017}).body[0].expression.body
Node {
  type: 'AwaitExpression',
  start: 12,
  end: 24,
  argument: Node {
    type: 'BinaryExpression',
    start: 18,
    end: 24,
    left: Node { type: 'Literal', start: 18, end: 19, value: 5, raw: '5' },
    operator: '**',
    right: Node { type: 'Literal', start: 23, end: 24, value: 6, raw: '6' }
  }
}

In chrome, this is a syntax error

async () => await 5 ** 6
VM40:1 Uncaught SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence

Babel PR babel/babel#12441

@nzakas
Copy link
Member

nzakas commented Mar 30, 2021

Can you please provide details in this issue? A link to a PR isn’t enough for us to evaluate this.

@fisker
Copy link
Contributor Author

fisker commented Mar 30, 2021

I updated the issue description.

@nzakas
Copy link
Member

nzakas commented Mar 31, 2021

Thanks. This is actually an issue with Acorn, which Espree wraps. I’d suggest opening an issue there. We can pull in the updated version when it’s fixed.

@fisker
Copy link
Contributor Author

fisker commented Apr 8, 2021

I think acorn already fixed it acornjs/acorn@848d14e

@nzakas
Copy link
Member

nzakas commented Apr 9, 2021

Awesome, then we can look at incorporating it.

@mdjermanovic
Copy link
Member

@fisker it seems that the latest Acorn still doesn't throw an error on this particular example. Can you open an issue on https://github.com/acornjs/acorn repository?

nzakas pushed a commit that referenced this issue Apr 16, 2021
* Breaking: acorn to 8.1.0

changelog:
https://github.com/acornjs/acorn/blob/master/acorn/CHANGELOG.md#breaking-changes

fixes #470, #472

* Update tests/lib/parse.js

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>

* fix: add ecmaversion>5

* fix: remove #472 test case

Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
@robpalme
Copy link

robpalme commented Apr 28, 2021

@mdjermanovic as you requested, I have opened an issue and created a PR to fix this in Acorn.

@fisker
Copy link
Contributor Author

fisker commented Apr 28, 2021

Somehow, I missed this. Thank you @robpalme!

@mdjermanovic
Copy link
Member

@robpalme thanks!

@robpalme
Copy link

This is now fixed in the Acorn 8.2.2 release.

@nzakas
Copy link
Member

nzakas commented Apr 30, 2021

You are my hero @robpalme. Thank you.

@nzakas nzakas removed the blocked label Apr 30, 2021
@nzakas nzakas linked a pull request Apr 30, 2021 that will close this issue
@nzakas nzakas moved this to Complete in Triage Jan 3, 2023
@nzakas nzakas added this to Triage Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants