-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Grammar ambiguity in for ( async of
#2034
Comments
why allow keyword like |
Because they’ve always been allowed, and it wouldn’t be web compatible to disallow them now. |
Implements tc39/ecma262#2034 Currently the token sequence `for (async of` is ambiguous. It can be the prefix for either `(async of => {};;);` or `for (async of foo);`. This CL disallows the token sequence. Note that `for await (async of` is still allowed, since there is no C-style `for await (;;)`, and thus no ambiguity. Bug: v8:11412 Change-Id: I3fede83a69420996baa2bc8b6c1cff000535d990 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2683221 Commit-Queue: Shu-yu Guo <[email protected]> Reviewed-by: Marja Hölttä <[email protected]> Cr-Commit-Position: refs/heads/master@{#72607}
For reference, the following code prints var async;
for (async of [42]) {}
console.log(async); |
For a while, the code 'for (async of []);' is ambiguous in the JS standard. It's going to be made unambiguously a SyntaxError. Make quick-lint-js report an error for this code, treating 'async' as a variable name, and gracefully continue. Many other forms, such as 'for (async.prop of []);' and 'for (async of => {}; cond; update);' are unambiguous, and shouldn't result in any errors. This commit adds tests for these similar cases. Discussion on the ambiguity and its resolution: tc39/ecma262#2034
For a while, the code 'for (async of []);' is ambiguous in the JS standard. It's going to be made unambiguously a SyntaxError. Make quick-lint-js report an error for this code, treating 'async' as a variable name, and gracefully continue. Many other forms, such as 'for (async.prop of []);' and 'for (async of => {}; cond; update);' are unambiguous, and shouldn't result in any errors. This commit adds tests for these similar cases. Discussion on the ambiguity and its resolution: tc39/ecma262#2034
For a while, the code 'for (async of []);' is ambiguous in the JS standard. It's going to be made unambiguously a SyntaxError. Make quick-lint-js report an error for this code, treating 'async' as a variable name, and gracefully continue. Many other forms, such as 'for (async.prop of []);' and 'for (async of => {}; cond; update);' are unambiguous, and shouldn't result in any errors. This commit adds tests for these similar cases. Discussion on the ambiguity and its resolution: tc39/ecma262#2034
@strager A fix was recently merged (https://chromium-review.googlesource.com/c/v8/v8/+/2683221), and Chrome 90 / V8 9.0 will correctly disallow |
The token sequence
for ( async of
can begin two different parses: eitherfor (async of => {};;);
orfor (async of foo);
.@waldemarhorwat raised this issue at the December 2019 meeting. During that discussion we decided to resolve this by using a lookahead restriction to disallow for-of loops which start with the token
async
.The text was updated successfully, but these errors were encountered: