Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 354f1c33187a33196be7b7db2813f089baa507b3..6497833d14869269ac8e0930496fec2fc5b0ae03 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -4088,7 +4088,11 @@ void ParserTraits::ParseArrowFunctionFormalParameters( |
parser_->scope_, parameters->scope); |
} |
- AddFormalParameter(parameters, expr, initializer, is_rest); |
+ // TODO(adamk): params_loc.end_pos is not the correct initializer position, |
+ // but it should be conservative enough to trigger hole checks for variables |
+ // referenced in the initializer (if any). |
+ AddFormalParameter(parameters, expr, initializer, params_loc.end_pos, |
+ is_rest); |
} |
@@ -4550,7 +4554,15 @@ Block* Parser::BuildParameterInitializationBlock( |
descriptor.is_const = false; |
descriptor.needs_init = true; |
descriptor.declaration_pos = parameter.pattern->position(); |
+ // The position that will be used by the AssignmentExpression |
+ // which copies from the temp parameter to the pattern. |
+ // |
+ // TODO(adamk): Should this be RelocInfo::kNoPosition, since |
+ // it's just copying from a temp var to the real param var? |
descriptor.initialization_pos = parameter.pattern->position(); |
+ // The initializer position which will end up in, |
+ // Variable::initializer_position(), used for hole check elimination. |
+ int initializer_position = parameter.pattern->position(); |
Expression* initial_value = |
factory()->NewVariableProxy(parameters.scope->parameter(i)); |
if (parameter.initializer != nullptr) { |
@@ -4565,6 +4577,7 @@ Block* Parser::BuildParameterInitializationBlock( |
condition, parameter.initializer, initial_value, |
RelocInfo::kNoPosition); |
descriptor.initialization_pos = parameter.initializer->position(); |
+ initializer_position = parameter.initializer_end_position; |
} else if (parameter.is_rest) { |
// $rest = []; |
// for (var $argument_index = $rest_index; |
@@ -4576,7 +4589,6 @@ Block* Parser::BuildParameterInitializationBlock( |
DCHECK(parameter.pattern->IsVariableProxy()); |
DCHECK_EQ(i, parameters.params.length() - 1); |
- int pos = parameter.pattern->position(); |
Variable* temp_var = parameters.scope->parameter(i); |
auto empty_values = new (zone()) ZoneList<Expression*>(0, zone()); |
auto empty_array = factory()->NewArrayLiteral( |
@@ -4640,8 +4652,6 @@ Block* Parser::BuildParameterInitializationBlock( |
zone()); |
init_block->statements()->Add(loop, zone()); |
- |
- descriptor.initialization_pos = pos; |
} |
Scope* param_scope = scope_; |
@@ -4660,7 +4670,7 @@ Block* Parser::BuildParameterInitializationBlock( |
{ |
BlockState block_state(&scope_, param_scope); |
DeclarationParsingResult::Declaration decl( |
- parameter.pattern, parameter.pattern->position(), initial_value); |
+ parameter.pattern, initializer_position, initial_value); |
PatternRewriter::DeclareAndInitializeVariables(param_block, &descriptor, |
&decl, nullptr, CHECK_OK); |
} |