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

Unified Diff: src/parser.cc

Issue 1314543005: [es6] Fix default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: These workj Created 5 years, 4 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 | « no previous file | test/cctest/test-parsing.cc » ('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 9334a33195a1e21f474055863bc28dd47fa2cb93..11a255c94e3d568231846fc406898b4425a2844f 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3904,6 +3904,7 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
parameters->is_simple = !is_rest && expr->IsVariableProxy();
}
+ Expression* initializer = nullptr;
if (expr->IsVariableProxy()) {
// When the formal parameter was originally seen, it was parsed as a
// VariableProxy and recorded as unresolved in the scope. Here we undo that
@@ -3911,18 +3912,12 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
// patterns; for patterns that happens uniformly in
// PatternRewriter::VisitVariableProxy).
parser_->scope_->RemoveUnresolved(expr->AsVariableProxy());
- }
-
- Expression* initializer = nullptr;
- if (!is_rest && parser_->allow_harmony_default_parameters() &&
- parser_->Check(Token::ASSIGN)) {
- ExpressionClassifier init_classifier;
- initializer =
- parser_->ParseAssignmentExpression(true, &init_classifier, ok);
- if (!*ok) return;
- parser_->ValidateExpression(&init_classifier, ok);
- if (!*ok) return;
- parameters->is_simple = false;
+ } else if (expr->IsAssignment()) {
+ Assignment* assignment = expr->AsAssignment();
+ DCHECK(parser_->allow_harmony_default_parameters());
+ DCHECK(!assignment->is_compound());
+ initializer = assignment->value();
+ expr = assignment->target();
}
AddFormalParameter(parameters, expr, initializer, is_rest);
« no previous file with comments | « no previous file | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698