Index: src/parsing/parser-base.h |
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
index de30e1bc5420eecdb42810f53c16976baa6b8235..03ef462bf71f6d1b1e7e257a240b035dc61d83d9 100644 |
--- a/src/parsing/parser-base.h |
+++ b/src/parsing/parser-base.h |
@@ -2281,7 +2281,6 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
// ArrowFunction |
// YieldExpression |
// LeftHandSideExpression AssignmentOperator AssignmentExpression |
- bool is_destructuring_assignment = false; |
int lhs_beg_pos = peek_position(); |
if (peek() == Token::YIELD && is_generator()) { |
@@ -2376,21 +2375,38 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
return expression; |
} |
+ // "expression" was not itself an arrow function parameter list, but it might |
+ // form part of one. Propagate speculative formal parameter error locations |
+ // (including those for binding patterns, since formal parameters can |
+ // themselves contain binding patterns). |
+ // Do not merge pending non-pattern expressions yet! |
+ unsigned productions = |
+ ExpressionClassifier::FormalParametersProductions | |
+ ExpressionClassifier::AsyncArrowFormalParametersProduction | |
+ ExpressionClassifier::FormalParameterInitializerProduction; |
+ |
+ // Parenthesized identifiers and property references are allowed as part |
+ // of a larger binding pattern, even though parenthesized patterns |
+ // themselves are not allowed, e.g., "[(x)] = []". Only accumulate |
+ // assignment pattern errors if the parsed expression is more complex. |
if (this->IsValidReferenceExpression(expression)) { |
- arrow_formals_classifier.ForgiveAssignmentPatternError(); |
+ productions |= ExpressionClassifier::PatternProductions & |
+ ~ExpressionClassifier::AssignmentPatternProduction; |
+ } else { |
+ productions |= ExpressionClassifier::PatternProductions; |
} |
- // "expression" was not itself an arrow function parameter list, but it might |
- // form part of one. Propagate speculative formal parameter error locations. |
- // Do not merge pending non-pattern expressions yet! |
- classifier->Accumulate( |
- &arrow_formals_classifier, |
- ExpressionClassifier::ExpressionProductions | |
- ExpressionClassifier::PatternProductions | |
- ExpressionClassifier::FormalParametersProductions | |
- ExpressionClassifier::ObjectLiteralProduction | |
- ExpressionClassifier::AsyncArrowFormalParametersProduction, |
- false); |
+ const bool is_destructuring_assignment = |
+ IsValidPattern(expression) && peek() == Token::ASSIGN; |
+ if (!is_destructuring_assignment) { |
+ // This may be an expression or a pattern, so we must continue to |
+ // accumulate expression-related errors. |
+ productions |= ExpressionClassifier::ExpressionProduction | |
+ ExpressionClassifier::TailCallExpressionProduction | |
+ ExpressionClassifier::ObjectLiteralProduction; |
+ } |
+ |
+ classifier->Accumulate(&arrow_formals_classifier, productions, false); |
if (!Token::IsAssignmentOp(peek())) { |
// Parsed conditional expression only (no assignment). |
@@ -2404,10 +2420,8 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
CheckNoTailCallExpressions(classifier, CHECK_OK); |
- if (IsValidPattern(expression) && peek() == Token::ASSIGN) { |
- classifier->ForgiveObjectLiteralError(); |
+ if (is_destructuring_assignment) { |
ValidateAssignmentPattern(classifier, CHECK_OK); |
- is_destructuring_assignment = true; |
} else { |
expression = this->CheckAndRewriteReferenceExpression( |
expression, lhs_beg_pos, scanner()->location().end_pos, |