You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 926bafc
Browse filesBrowse the repository at this point in the historyBrowse files
[JSC] Fix let, async of and destructuring declarations in for heads
https://bugs.webkit.org/show_bug.cgi?id=327243
Reviewed by Yusuke Suzuki.
This patch fixes three bugs in parseForStatement().
1. In sloppy mode, `let` is an identifier unless it starts a declaration,
so `for (let in obj)`, `for (let; ;)` and `for (let = 3; ;)` are valid.
We consume `let` and look at the next token, and go back only when
`let` turns out to be an identifier, so a declaration is not lexed twice.
`for (let.x of [])` stays a SyntaxError.
2. `for await (async of [])` is valid: only for-of has the
[lookahead ≠ async of] restriction. We also apply that restriction to
`for (async\nof [])`, which was accepted.
3. A destructuring declaration needs an initializer unless it is the
binding of for-in or for-of, so `for (let [a]; ;)` is a SyntaxError.
Tests: JSTests/stress/for-await-of-head-async-identifier.js
JSTests/stress/for-statement-head-destructuring-declaration-requires-initializer.js
JSTests/stress/for-statement-head-let-identifier-sloppy.js
* JSTests/stress/for-statement-head-let-identifier-sloppy.js: Added.
(shouldBe):
(shouldBeSyntaxError):
(let):
(inFunction):
(inGenerator):
(async 9):
(let.async of):
(shouldBeSyntaxError.async f):
* JSTests/test262/expectations-linux.yaml:
* JSTests/test262/expectations.yaml:
* LayoutTests/js/let-syntax-expected.txt:
* LayoutTests/js/script-tests/let-syntax.js:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseForStatement):
(JSC::Parser<LexerType>::parseVariableDeclarationList):
(JSC::Parser<LexerType>::parseVariableDeclaration):
* JSTests/stress/for-await-of-head-async-identifier.js: Added.
(shouldBe):
(shouldBeSyntaxError):
(async test.async shouldBe):
(async var):
(async catch):
(async shouldBeSyntaxError):
* JSTests/stress/for-let-comma.js:
(foo):
* JSTests/stress/for-statement-head-destructuring-declaration-requires-initializer.js: Added.
(shouldBe):
(shouldBeSyntaxError):
(shouldBeSyntaxError.async f):
* Source/JavaScriptCore/parser/Parser.h:
Canonical link: https://commits.webkit.org/324319@main
0 commit comments