Fix scope flags for default parameters
R=rossberg,adamk BUG=chromium:616386 Review-Url: https://codereview.chromium.org/2042793002 Cr-Commit-Position: refs/heads/master@{#36755}
This commit is contained in:
parent
f1ffe31163
commit
4cc1331c34
@ -4554,6 +4554,7 @@ Block* Parser::BuildParameterInitializationBlock(
|
||||
DCHECK(scope_->is_function_scope());
|
||||
Block* init_block =
|
||||
factory()->NewBlock(NULL, 1, true, RelocInfo::kNoPosition);
|
||||
ZoneList<Scope*>* param_scopes = new (zone()) ZoneList<Scope*>(0, zone());
|
||||
for (int i = 0; i < parameters.params.length(); ++i) {
|
||||
auto parameter = parameters.params[i];
|
||||
if (parameter.is_rest && parameter.pattern->IsVariableProxy()) break;
|
||||
@ -4595,12 +4596,13 @@ Block* Parser::BuildParameterInitializationBlock(
|
||||
|
||||
Scope* param_scope = scope_;
|
||||
Block* param_block = init_block;
|
||||
if (!parameter.is_simple() && scope_->calls_sloppy_eval()) {
|
||||
if (!parameter.is_simple()) {
|
||||
param_scope = NewScope(scope_, BLOCK_SCOPE);
|
||||
param_scope->set_is_declaration_scope();
|
||||
param_scope->set_start_position(descriptor.initialization_pos);
|
||||
param_scope->set_end_position(parameter.initializer_end_position);
|
||||
param_scope->RecordEvalCall();
|
||||
param_scopes->Add(param_scope, zone());
|
||||
scope_->PropagateUsageFlagsToScope(param_scope);
|
||||
param_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition);
|
||||
param_block->set_scope(param_scope);
|
||||
descriptor.hoist_scope = scope_;
|
||||
@ -4614,7 +4616,7 @@ Block* Parser::BuildParameterInitializationBlock(
|
||||
&decl, nullptr, CHECK_OK);
|
||||
}
|
||||
|
||||
if (!parameter.is_simple() && scope_->calls_sloppy_eval()) {
|
||||
if (!parameter.is_simple()) {
|
||||
param_scope = param_scope->FinalizeBlockScope();
|
||||
if (param_scope != nullptr) {
|
||||
CheckConflictingVarDeclarations(param_scope, CHECK_OK);
|
||||
@ -4622,6 +4624,9 @@ Block* Parser::BuildParameterInitializationBlock(
|
||||
init_block->statements()->Add(param_block, zone());
|
||||
}
|
||||
}
|
||||
for (Scope* param_scope : *param_scopes) {
|
||||
scope_->PropagateUsageFlagsToScope(param_scope);
|
||||
}
|
||||
return init_block;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user