[webkit-changes] [WebKit/WebKit] 6bef02: [JSC] Align negative lookahead assertion of Expres...

Commit Queue noreply at github.com
Tue Oct 17 15:22:10 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 6bef023b77340f57b012fc860204a304ab01a6c1
      https://github.com/WebKit/WebKit/commit/6bef023b77340f57b012fc860204a304ab01a6c1
  Author: Alexey Shvayka <ashvayka at apple.com>
  Date:   2023-10-17 (Tue, 17 Oct 2023)

  Changed paths:
    M JSTests/ChakraCore/test/LetConst/r.baseline-jsc
    M JSTests/stress/let-and-open-bracket.js
    M JSTests/test262/expectations.yaml
    M LayoutTests/inspector/runtime/parse-expected.txt
    M LayoutTests/js/binary-literals-expected.txt
    M LayoutTests/js/let-syntax-expected.txt
    M LayoutTests/js/octal-literals-expected.txt
    M LayoutTests/js/parser-error-messages-expected.txt
    M LayoutTests/js/parser-syntax-check-expected.txt
    M LayoutTests/js/script-tests/parser-error-messages.js
    M LayoutTests/js/script-tests/parser-syntax-check.js
    M Source/JavaScriptCore/parser/Parser.cpp

  Log Message:
  -----------
  [JSC] Align negative lookahead assertion of ExpressionStatement with the spec
https://bugs.webkit.org/show_bug.cgi?id=262456
<rdar://problem/116299721>

Reviewed by Yusuke Suzuki.

This change makes parseExpressionOrLabelStatement() call into parseExpressionStatement() as its second
exit point, and moves `let [` negative lookahead assertion there, which is necessary to throw an early
error for cases like `foo: let [`. Before this patch, JSC was incorrectly throwing a ReferenceError on
`let` in sloppy mode.

We were handling `foo: class` correctly already because matchSpecIdentifier() doesn't match `class`,
making parseExpressionOrLabelStatement() to take the parseStatement() path.

Also, this change implements `async [no LineTerminator here] function` negative lookahead assertion
of the ExpressionStatement [1], which is necessary to avoid ambiguity with an AsyncFunctionDeclaration
or an AsyncGeneratorDeclaration. Before this patch, JSC was incorrectly parsing `foo: async function() {}`
as an AsyncFunctionExpression.

Additionally, this change cleans up error messages from useless "Parse error".

Aligns JSC with V8 and SpiderMonkey.

[1]: https://tc39.es/ecma262/#prod-ExpressionStatement

* JSTests/ChakraCore/test/LetConst/r.baseline-jsc:
* JSTests/stress/let-and-open-bracket.js:
* JSTests/test262/expectations.yaml: Mark 5 tests as passing.
* LayoutTests/inspector/runtime/parse-expected.txt:
* LayoutTests/js/binary-literals-expected.txt:
* LayoutTests/js/let-syntax-expected.txt:
* LayoutTests/js/octal-literals-expected.txt:
* LayoutTests/js/parser-error-messages-expected.txt:
* LayoutTests/js/parser-syntax-check-expected.txt:
* LayoutTests/js/script-tests/parser-error-messages.js:
* LayoutTests/js/script-tests/parser-syntax-check.js:
* Source/JavaScriptCore/parser/Parser.cpp:
(JSC::Parser<LexerType>::parseStatement):
(JSC::Parser<LexerType>::parseExpressionOrLabelStatement):
(JSC::Parser<LexerType>::parseExpressionStatement):

Canonical link: https://commits.webkit.org/269430@main




More information about the webkit-changes mailing list