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

Unified Diff: src/parser.cc

Issue 1167393005: [destructuring] Parse binding patterns in formal parameters. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: CR feedback + rebase Created 5 years, 6 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/parser.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 c3297b0d6beb4be727d9b4093dd8ee2fd5d3afd2..41a5d36b04ca84962ac1e40fa9c44b4c32e351e3 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1183,13 +1183,19 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
scope->set_start_position(shared_info->start_position());
ExpressionClassifier formals_classifier;
bool has_rest = false;
- if (Check(Token::LPAREN)) {
- // '(' StrictFormalParameters ')'
- ParseFormalParameterList(scope, &has_rest, &formals_classifier, &ok);
- if (ok) ok = Check(Token::RPAREN);
- } else {
- // BindingIdentifier
- ParseFormalParameter(scope, has_rest, &formals_classifier, &ok);
+ {
+ // Parsing patterns as variable reference expression creates
+ // NewUnresolved references in current scope. Entrer arrow function
+ // scope for formal parameter parsing.
+ BlockState block_state(&scope_, scope);
+ if (Check(Token::LPAREN)) {
+ // '(' StrictFormalParameters ')'
+ ParseFormalParameterList(scope, &has_rest, &formals_classifier, &ok);
+ if (ok) ok = Check(Token::RPAREN);
+ } else {
+ // BindingIdentifier
+ ParseFormalParameter(scope, has_rest, &formals_classifier, &ok);
+ }
}
if (ok) {
@@ -3805,7 +3811,10 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
expr = expr->AsSpread()->expression();
}
- DCHECK(expr->IsVariableProxy());
+ if (!expr->IsVariableProxy()) {
+ // TODO(dslomov): support pattern desugaring
+ return;
+ }
DCHECK(!expr->AsVariableProxy()->is_this());
const AstRawString* raw_name = expr->AsVariableProxy()->raw_name();
@@ -3818,7 +3827,7 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
parser_->scope_->RemoveUnresolved(expr->AsVariableProxy());
ExpressionClassifier classifier;
- DeclareFormalParameter(scope, raw_name, &classifier, *has_rest);
+ DeclareFormalParameter(scope, expr, &classifier, *has_rest);
if (!duplicate_loc->IsValid()) {
*duplicate_loc = classifier.duplicate_formal_parameter_error().location;
}
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698