Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Unified Diff: src/parsing/parser-base.h

Issue 1656993002: [parser] report invalid rest parameter errors in Arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: group tests/remove unneeded stuff Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/messages.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index b54273f1ad84ec6f7cfebc4dc08e16b9b5ff503a..c11381672aa6f705745ea9c6fc6fcfc090a30eda 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);
@@ -1458,7 +1464,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(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,
« no previous file with comments | « src/messages.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698