Changeset 266324 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Aug 29, 2020, 1:38:09 AM (5 years ago)
Author:
[email protected]
Message:

[JSC] for-of / for-in left-hand-side target should be simple-assignment-target
https://bugs.webkit.org/show_bug.cgi?id=215969

Reviewed by Ross Kirsling.

JSTests:

  • stress/for-of-in-non-reference.js: Added.

(testSyntax):
(testSyntaxError):
(testSyntaxError.t):
(testSyntaxError.async t):
(testSyntax.async t):

  • test262/expectations.yaml:

Source/JavaScriptCore:

Left-hand-side of for-in, for-of, and for-await-of should be simple assignment target[1]
if the target is not declaration and not destructuring pattern.

[1]: https://tc39.es/ecma262/#sec-for-in-and-for-of-statements-static-semantics-early-errors

  • parser/Parser.cpp:

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

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createCommaExpr): Should return CommaExpr to align it to ASTBuilder.
(JSC::SyntaxChecker::appendToCommaExpr):
(JSC::SyntaxChecker::appendStatement):
(JSC::SyntaxChecker::combineCommaNodes): Deleted since it is not used.

LayoutTests:

Fix for-in / for-of parser behavior.

  • js/basic-strict-mode-expected.txt:
  • js/parser-syntax-check-expected.txt:
  • js/script-tests/parser-syntax-check.js:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r266323 r266324  
     12020-08-28  Yusuke Suzuki  <[email protected]>
     2
     3        [JSC] for-of / for-in left-hand-side target should be simple-assignment-target
     4        https://bugs.webkit.org/show_bug.cgi?id=215969
     5
     6        Reviewed by Ross Kirsling.
     7
     8        Left-hand-side of `for-in`, `for-of`, and `for-await-of` should be simple assignment target[1]
     9        if the target is not declaration and not destructuring pattern.
     10
     11        [1]: https://tc39.es/ecma262/#sec-for-in-and-for-of-statements-static-semantics-early-errors
     12
     13        * parser/Parser.cpp:
     14        (JSC::Parser<LexerType>::parseForStatement):
     15        * parser/SyntaxChecker.h:
     16        (JSC::SyntaxChecker::createCommaExpr): Should return CommaExpr to align it to ASTBuilder.
     17        (JSC::SyntaxChecker::appendToCommaExpr):
     18        (JSC::SyntaxChecker::appendStatement):
     19        (JSC::SyntaxChecker::combineCommaNodes): Deleted since it is not used.
     20
    1212020-08-28  Yusuke Suzuki  <[email protected]>
    222
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r266322 r266324  
    15431543        return result;
    15441544    }
     1545
     1546    semanticFailIfFalse(isSimpleAssignmentTarget(context, decls), "Left side of assignment is not a reference");
    15451547    if (isOfEnumeration)
    15461548        result = context.createForOfLoop(isAwaitFor, location, decls, expr, statement, declLocation, declsStart, declsEnd, exprEnd, startLine, endLine, *lexicalVariables);
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r266264 r266324  
    148148    int createSourceElements() { return SourceElementsResult; }
    149149    ExpressionType makeFunctionCallNode(const JSTokenLocation&, ExpressionType, bool, int, int, int, int, size_t, bool) { return CallExpr; }
    150     ExpressionType createCommaExpr(const JSTokenLocation&, ExpressionType expr) { return expr; }
    151     ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType& head, ExpressionType, ExpressionType next) { head = next; return next; }
     150    ExpressionType createCommaExpr(const JSTokenLocation&, ExpressionType) { return CommaExpr; }
     151    ExpressionType appendToCommaExpr(const JSTokenLocation&, ExpressionType, ExpressionType, ExpressionType) { return CommaExpr; }
    152152    ExpressionType makeAssignNode(const JSTokenLocation&, ExpressionType, Operator, ExpressionType, bool, bool, int, int, int) { return AssignmentExpr; }
    153153    ExpressionType makePrefixNode(const JSTokenLocation&, ExpressionType, Operator, int, int, int) { return PreExpr; }
     
    302302
    303303    void appendStatement(int, int) { }
    304     int combineCommaNodes(const JSTokenLocation&, int, int) { return CommaExpr; }
    305304    int evalCount() const { return 0; }
    306305    void appendBinaryExpressionInfo(int& operandStackDepth, int expr, int, int, int, bool)
Note: See TracChangeset for help on using the changeset viewer.