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

Unified Diff: src/parser.cc

Issue 1123383005: Rely on ExpressionClassifier to match valid arrow function formals (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Created 5 years, 7 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/ast.h ('k') | src/preparser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 0c0daf8e6893560349211496bb8edc00775a7aa9..0dbbaffb8c3a05b6b8284f4375337b335a166150 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3737,19 +3737,11 @@ void ParserTraits::DeclareArrowFunctionParameters(
// need to match the pre-parser's behavior.
if (expr->IsBinaryOperation()) {
BinaryOperation* binop = expr->AsBinaryOperation();
- // TODO(wingo): These checks are now unnecessary, given the classifier.
- if (binop->op() != Token::COMMA) {
- ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
- *ok = false;
- return;
- }
+ // The classifier has already run, so we know that the expression is a valid
+ // arrow function formals production.
+ DCHECK_EQ(binop->op(), Token::COMMA);
Expression* left = binop->left();
Expression* right = binop->right();
- if (left->is_single_parenthesized() || right->is_single_parenthesized()) {
- ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
- *ok = false;
- return;
- }
DeclareArrowFunctionParameters(scope, left, params_loc, duplicate_loc, ok);
if (!*ok) return;
// LHS of comma expression should be unparenthesized.
@@ -3757,22 +3749,13 @@ void ParserTraits::DeclareArrowFunctionParameters(
}
// TODO(wingo): Support rest parameters.
- if (!expr->IsVariableProxy()) {
- ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
- *ok = false;
- return;
- }
+ DCHECK(expr->IsVariableProxy());
+ DCHECK(!expr->AsVariableProxy()->is_this());
const AstRawString* raw_name = expr->AsVariableProxy()->raw_name();
Scanner::Location param_location(expr->position(),
expr->position() + raw_name->length());
- if (expr->AsVariableProxy()->is_this()) {
- ReportMessageAt(param_location, "this_formal_parameter");
- *ok = false;
- return;
- }
-
// When the formal parameter was originally seen, it was parsed as a
// VariableProxy and recorded as unresolved in the scope. Here we undo that
// parse-time side-effect.
@@ -3790,15 +3773,6 @@ void ParserTraits::DeclareArrowFunctionParameters(
void ParserTraits::ParseArrowFunctionFormalParameters(
Scope* scope, Expression* params, const Scanner::Location& params_loc,
bool* is_rest, Scanner::Location* duplicate_loc, bool* ok) {
- // Too many parentheses around expression:
- // (( ... )) => ...
- if (params->is_multi_parenthesized()) {
- // TODO(wingo): Make a better message.
- ReportMessageAt(params_loc, "malformed_arrow_function_parameter_list");
- *ok = false;
- return;
- }
-
DeclareArrowFunctionParameters(scope, params, params_loc, duplicate_loc, ok);
}
« no previous file with comments | « src/ast.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698