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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.