Ignore:
Timestamp:
Aug 29, 2020, 1:44:20 PM (5 years ago)
Author:
[email protected]
Message:

[JSC] let [ sequence cannot appear in ExpressionStatement context
https://bugs.webkit.org/show_bug.cgi?id=215977

Reviewed by Ross Kirsling.

JSTests:

  • stress/let-and-open-bracket.js: Added.

(testSyntax):
(testSyntaxError):

  • test262/expectations.yaml:

Source/JavaScriptCore:

Because of ambiguity between destructuring assignment and member access (let IDENTIFIER), ECMA262 does not allow let [ sequence in ExpressionStatement context[1].
We should throw SyntaxError when we see something like this.

if (false)

let [ok] = [42];

[1]: https://tc39.es/ecma262/#sec-expression-statement

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseStatement):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r266326 r266327  
    19711971        return 0;
    19721972    case LET: {
     1973        // https://tc39.es/ecma262/#sec-expression-statement
     1974        // ExpressionStatement's lookahead includes `let [` sequence.
     1975        SavePoint savePoint = createSavePoint(context);
     1976        next();
     1977        failIfTrue(match(OPENBRACKET), "Cannot use lexical declaration in single-statement context");
     1978        restoreSavePoint(context, savePoint);
    19731979        if (!strictMode())
    19741980            goto identcase;
Note: See TracChangeset for help on using the changeset viewer.