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

Unified Diff: src/parsing/parser.cc

Issue 2171703004: Rescope arrow-function parameter lists by moving the delta to the parameter scope (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unnecessary DCHECK Created 4 years, 5 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/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 0e97efdf94793c904171b4db9495dd39b7b52b53..45f04b04aeb982fa84c3d79c53e9b9c7be85978e 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -4122,22 +4122,11 @@ void ParserTraits::ParseArrowFunctionFormalParameters(
}
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
- // parse-time side-effect for parameters that are single-names (not
- // patterns; for patterns that happens uniformly in
- // PatternRewriter::VisitVariableProxy).
- parser_->scope()->RemoveUnresolved(expr->AsVariableProxy());
- } else if (expr->IsAssignment()) {
+ if (expr->IsAssignment()) {
Assignment* assignment = expr->AsAssignment();
DCHECK(!assignment->is_compound());
initializer = assignment->value();
expr = assignment->target();
-
- // TODO(adamk): Only call this if necessary.
- RewriteParameterInitializerScope(parser_->stack_limit(), initializer,
- parser_->scope(), parameters->scope);
}
AddFormalParameter(parameters, expr, initializer, end_pos, is_rest);
@@ -4217,16 +4206,17 @@ DoExpression* Parser::ParseDoExpression(bool* ok) {
return expr;
}
-
void ParserTraits::ParseArrowFunctionFormalParameterList(
ParserFormalParameters* parameters, Expression* expr,
- const Scanner::Location& params_loc,
- Scanner::Location* duplicate_loc, bool* ok) {
+ const Scanner::Location& params_loc, Scanner::Location* duplicate_loc,
+ const Scope::Snapshot& scope_snapshot, bool* ok) {
if (expr->IsEmptyParentheses()) return;
ParseArrowFunctionFormalParameters(parameters, expr, params_loc.end_pos,
CHECK_OK_VOID);
+ scope_snapshot.Reparent(parameters->scope);
+
if (parameters->Arity() > Code::kMaxArguments) {
ReportMessageAt(params_loc, MessageTemplate::kMalformedArrowFunParamList);
*ok = false;
@@ -4715,7 +4705,7 @@ Block* Parser::BuildParameterInitializationBlock(
// rewrite inner initializers of the pattern to param_scope
descriptor.scope = param_scope;
// Rewrite the outer initializer to point to param_scope
- RewriteParameterInitializerScope(stack_limit(), initial_value, scope(),
+ ReparentParameterExpressionScope(stack_limit(), initial_value,
param_scope);
}
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698