WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
203478
Poor Async/Await Syntax Error Message
https://bugs.webkit.org/show_bug.cgi?id=203478
Summary
Poor Async/Await Syntax Error Message
Ezekiel Elin
Reported
2019-10-27 19:47:38 PDT
The `await` keyword can only be used in functions marked `async.` When one tries to use it in a function not marked as such, evaluation fails with the error: function b() { const x = await "Hello"; } SyntaxError: Unexpected string literal "Hello". Expected ';' after variable declaration. This should instead say something like (copied from Firefox): SyntaxError: await is only valid in async functions and async generators The correct code is: async function b() { const x = await "Hello"; }
Attachments
Add attachment
proposed patch, testcase, etc.
Ross Kirsling
Comment 1
2019-10-28 16:07:31 PDT
That would be a more helpful error message indeed. Note that the reason for the current error message is that `await` is a valid *identifier* just when we're *not* in an async function. So this is all perfectly valid code (for web compatibility reasons): const await = "Hello"; const x = await; function f(await) { console.log(await); }
Radar WebKit Bug Importer
Comment 2
2022-04-07 13:09:27 PDT
<
rdar://problem/91439731
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug