Should throw on `async () => await 5 ** 6;`
See original GitHub issueespree
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:
- Created 2 years ago
- Comments:11 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mdjermanovic as you requested, I have opened an issue and created a PR to fix this in Acorn.
You are my hero @robpalme. Thank you.