WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
217299
await expression breaks some surrounding expressions
https://bugs.webkit.org/show_bug.cgi?id=217299
Summary
await expression breaks some surrounding expressions
thatcomputerguy0101
Reported
2020-10-04 15:01:45 PDT
The `await` operator is not treated like a standard operator, since it breaks whenever used in several expression contexts. The following two constructs are both broken by this bug, and I expect a few more to be as well: let {property} = await asyncFunction() // results in SyntaxError: Unexpected identifier 'asyncFunction'. Expected ';' after variable declaration. const result = await asyncFunction() // results in SyntaxError: Unexpected token ';'. const declared variable 'result' must have an initializer. I expect this happens because the await operator tries to take some sort of assignment shortcut. The `await` operator is supposed to be just another operator (that happens to take an undefined duration), so it shouldn't matter where it is used. In Chrome, both of the above will work without errors (when run in the appropriate context).
Attachments
Add attachment
proposed patch, testcase, etc.
thatcomputerguy0101
Comment 1
2020-10-04 15:03:20 PDT
Additionally, I believe
Bug 203478
stems from this problem.
thatcomputerguy0101
Comment 2
2020-10-04 16:07:36 PDT
I have to correct myself. This only occurs in contexts that are expected to be syncronous. However, it does occur when evaluating a console expression, which makes more sense to be async-compatible.
Radar WebKit Bug Importer
Comment 3
2020-10-05 17:25:00 PDT
<
rdar://problem/69978159
>
Yusuke Suzuki
Comment 4
2021-02-01 02:23:59 PST
ECMAScript "await" needs to be used inside async function. I think the example code is used in normal code, and the error should occur since this is not async function.
thatcomputerguy0101
Comment 5
2021-02-01 06:41:56 PST
Beyond the poor error message, the only problem here is that the Javascript debug console is partially async compatible, with expressions like the standard `var result = await asyncFunction()` working just fine and more complicated expressions like the ones listed in my original post do not. This does not affect their compatibility in a regular async environment, only in the debug console. Additionally, the following is another syntax form affected by this bug: var result = await (asyncFunction()) // results in ReferenceError: Can't find variable: await
Yusuke Suzuki
Comment 6
2021-02-01 10:31:10 PST
var result = await (asyncFunction()) // results in ReferenceError: Can't find variable: await This is correct since, inside normal function, this syntax is fine. "await" is not a keyword (it is contextual keyword). So if it is used in a normal function, then, it is possible that this is variable reference. You can write the following. function await() { } var result = await(30);
Yusuke Suzuki
Comment 7
2021-02-01 10:33:03 PST
I think this is related to Web Inspector's console's priority on whether we should parse the given code as async code or not. Sending it to Web Inspector category.
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