question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
robpalmecommented, Apr 28, 2021

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

1reaction
nzakascommented, Apr 30, 2021

You are my hero @robpalme. Thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Throwing immediately from async method - Stack Overflow
Your thread depends on the result of the async function to do its next processing, so the exception should be thrown on your...
Read more >
Why exceptions in async methods are “dangerous” in C#
No exception was thrown because the MyAsyncMethod routine is not awaited and the exception is literally lost with the Task.
Read more >
Common async / Task mistakes, and how to avoid them
When running the code as-is, everything works fine. The exception is thrown properly, since we await DoStuff(), which in turn means we are ......
Read more >
Async/Await - Best Practices in Asynchronous Programming
To summarize this first guideline, you should prefer async Task to async void. Async Task methods enable easier error-handling, composability and testability.
Read more >
Async/await - The Modern JavaScript Tutorial
If a promise resolves normally, then await promise returns the result. But in the case of a rejection, it throws the error, just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found