Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 816849748869720029796504e4d282dc6ca1bb2e..0edaceddde6ff00d1358dba96bf6e4a7c664de5e 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -3759,9 +3759,9 @@ Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { |
} |
-void ParserTraits::DeclareArrowFunctionParameters( |
+void ParserTraits::ParseArrowFunctionFormalParameters( |
Scope* scope, Expression* expr, const Scanner::Location& params_loc, |
- Scanner::Location* duplicate_loc, bool* ok) { |
+ bool has_rest, Scanner::Location* duplicate_loc, bool* ok) { |
if (scope->num_parameters() >= Code::kMaxArguments) { |
ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList); |
*ok = false; |
@@ -3785,13 +3785,15 @@ void ParserTraits::DeclareArrowFunctionParameters( |
DCHECK_EQ(binop->op(), Token::COMMA); |
Expression* left = binop->left(); |
Expression* right = binop->right(); |
- DeclareArrowFunctionParameters(scope, left, params_loc, duplicate_loc, ok); |
+ // Only the right-most expression may be a rest parameter. |
+ bool has_rest = false; |
+ ParseArrowFunctionFormalParameters(scope, left, params_loc, has_rest, |
+ duplicate_loc, ok); |
if (!*ok) return; |
// LHS of comma expression should be unparenthesized. |
expr = right; |
} |
- // TODO(wingo): Support rest parameters. |
DCHECK(expr->IsVariableProxy()); |
DCHECK(!expr->AsVariableProxy()->is_this()); |
@@ -3804,17 +3806,11 @@ void ParserTraits::DeclareArrowFunctionParameters( |
// parse-time side-effect. |
parser_->scope_->RemoveUnresolved(expr->AsVariableProxy()); |
- bool is_rest = false; |
ExpressionClassifier classifier; |
- DeclareFormalParameter(scope, raw_name, &classifier, is_rest); |
- *duplicate_loc = classifier.duplicate_formal_parameter_error().location; |
-} |
- |
- |
-void ParserTraits::ParseArrowFunctionFormalParameters( |
- Scope* scope, Expression* params, const Scanner::Location& params_loc, |
- bool* is_rest, Scanner::Location* duplicate_loc, bool* ok) { |
- DeclareArrowFunctionParameters(scope, params, params_loc, duplicate_loc, ok); |
+ DeclareFormalParameter(scope, raw_name, &classifier, has_rest); |
+ if (!duplicate_loc->IsValid()) { |
Dmitry Lomov (no reviews)
2015/06/10 11:04:41
Oops, thanks for fixing this! Can we add a test th
wingo
2015/06/10 13:21:10
Sure. I'll see if I can cook one up for this CL a
|
+ *duplicate_loc = classifier.duplicate_formal_parameter_error().location; |
+ } |
} |