Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index de30e1bc5420eecdb42810f53c16976baa6b8235..a92a38461ab821ed06882b18fcb3c05f4e8e2d37 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,37 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN, |
| return expression; |
| } |
| - if (this->IsValidReferenceExpression(expression)) { |
| - arrow_formals_classifier.ForgiveAssignmentPatternError(); |
| - } |
| - |
| // "expression" was not itself an arrow function parameter list, but it might |
| - // form part of one. Propagate speculative formal parameter error locations. |
| + // 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! |
| - classifier->Accumulate( |
| - &arrow_formals_classifier, |
| - ExpressionClassifier::ExpressionProductions | |
| - ExpressionClassifier::PatternProductions | |
| - ExpressionClassifier::FormalParametersProductions | |
| - ExpressionClassifier::ObjectLiteralProduction | |
| - ExpressionClassifier::AsyncArrowFormalParametersProduction, |
| - false); |
| + unsigned productions = |
| + ExpressionClassifier::BindingPatternProduction | |
| + ExpressionClassifier::LetPatternProduction | |
|
nickie
2016/08/23 08:24:27
I'd rather change this to:
(ExpressionClassifier::
adamk
2016/08/23 18:02:31
I've moved all the pattern logic down into the IsV
|
| + 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)) { |
| + productions |= ExpressionClassifier::AssignmentPatternProduction; |
| + } |
| + |
| + 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 +2419,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, |