Chromium Code Reviews| Index: src/parsing/parser-base.h |
| diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h |
| index b54273f1ad84ec6f7cfebc4dc08e16b9b5ff503a..195c355f421b1e954a3c488eba0bb31b2ba25ae8 100644 |
| --- a/src/parsing/parser-base.h |
| +++ b/src/parsing/parser-base.h |
| @@ -1329,8 +1329,14 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier, |
| MessageTemplate::kUnexpectedToken, |
| Token::String(Token::ELLIPSIS)); |
| classifier->RecordNonSimpleParameter(); |
| - ExpressionT expr = |
| - this->ParseAssignmentExpression(true, classifier, CHECK_OK); |
| + ExpressionT expr = this->ParseAssignmentExpression( |
| + true, kIsPossibleArrowFormals, classifier, CHECK_OK); |
| + if (!this->IsIdentifier(expr) && !expr->IsObjectLiteral() && |
| + !expr->IsArrayLiteral()) { |
| + classifier->RecordArrowFormalParametersError( |
| + Scanner::Location(ellipsis_pos, scanner()->location().end_pos), |
| + MessageTemplate::kInvalidRestParameter); |
| + } |
| if (peek() == Token::COMMA) { |
| ReportMessageAt(scanner()->peek_location(), |
| MessageTemplate::kParamAfterRest); |
| @@ -1446,10 +1452,12 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| } |
| Consume(Token::COMMA); |
| bool is_rest = false; |
| + int ellipsis_pos; |
|
adamk
2016/02/01 23:15:59
I think this is a dup of "pos", below.
caitp (gmail)
2016/02/01 23:19:37
Acknowledged.
|
| if (peek() == Token::ELLIPSIS) { |
| // 'x, y, ...z' in CoverParenthesizedExpressionAndArrowParameterList only |
| // as the formal parameters of'(x, y, ...z) => foo', and is not itself a |
| // valid expression or binding pattern. |
| + ellipsis_pos = peek_position(); |
| ExpressionUnexpectedToken(classifier); |
| BindingPatternUnexpectedToken(classifier); |
| Consume(Token::ELLIPSIS); |
| @@ -1458,7 +1466,15 @@ typename ParserBase<Traits>::ExpressionT ParserBase<Traits>::ParseExpression( |
| int pos = position(), expr_pos = peek_position(); |
| ExpressionT right = this->ParseAssignmentExpression( |
| accept_IN, flags, &binding_classifier, CHECK_OK); |
| - if (is_rest) right = factory()->NewSpread(right, pos, expr_pos); |
| + if (is_rest) { |
| + if (!this->IsIdentifier(right) && !right->IsObjectLiteral() && |
| + !right->IsArrayLiteral()) { |
| + classifier->RecordArrowFormalParametersError( |
| + Scanner::Location(ellipsis_pos, scanner()->location().end_pos), |
| + MessageTemplate::kInvalidRestParameter); |
| + } |
| + right = factory()->NewSpread(right, pos, expr_pos); |
| + } |
| is_simple_parameter_list = |
| is_simple_parameter_list && this->IsIdentifier(right); |
| classifier->Accumulate(binding_classifier, |