Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index e6c1c79a4159f9fa065912662d1822350f6fe221..79d06da50750fca179203bb8abd768b07043d76d 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -4309,11 +4309,8 @@ |
pair.assignment->AsRewritableExpression(); |
DCHECK_NOT_NULL(to_rewrite); |
if (!to_rewrite->is_rewritten()) { |
- // Since this function is called at the end of parsing the program, |
- // pair.scope may already have been removed by FinalizeBlockScope in the |
- // meantime. |
- Scope* scope = pair.scope->GetUnremovedScope(); |
- PatternRewriter::RewriteDestructuringAssignment(this, to_rewrite, scope); |
+ PatternRewriter::RewriteDestructuringAssignment(this, to_rewrite, |
+ pair.scope); |
} |
} |
} |
@@ -4748,7 +4745,7 @@ |
Block* then = factory()->NewBlock(nullptr, 4 + 1, false, nopos); |
BuildIteratorCloseForCompletion( |
- scope(), then->statements(), var_iterator, |
+ then->statements(), var_iterator, |
factory()->NewSmiLiteral(Parser::kNormalCompletion, nopos)); |
then->statements()->Add(throw_call, zone()); |
check_throw = factory()->NewIfStatement( |
@@ -5116,9 +5113,9 @@ |
statements->Add(validate_output, zone()); |
} |
-void Parser::FinalizeIteratorUse(Scope* use_scope, Variable* completion, |
- Expression* condition, Variable* iter, |
- Block* iterator_use, Block* target) { |
+void Parser::FinalizeIteratorUse(Variable* completion, Expression* condition, |
+ Variable* iter, Block* iterator_use, |
+ Block* target) { |
// |
// This function adds two statements to [target], corresponding to the |
// following code: |
@@ -5174,8 +5171,7 @@ |
{ |
Block* block = factory()->NewBlock(nullptr, 2, true, nopos); |
Expression* proxy = factory()->NewVariableProxy(completion); |
- BuildIteratorCloseForCompletion(use_scope, block->statements(), iter, |
- proxy); |
+ BuildIteratorCloseForCompletion(block->statements(), iter, proxy); |
DCHECK(block->statements()->length() == 2); |
maybe_close = factory()->NewBlock(nullptr, 1, true, nopos); |
@@ -5192,7 +5188,7 @@ |
// } |
Statement* try_catch; |
{ |
- Scope* catch_scope = NewScopeWithParent(use_scope, CATCH_SCOPE); |
+ Scope* catch_scope = NewScopeWithParent(scope(), CATCH_SCOPE); |
Variable* catch_variable = |
catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
kCreatedInitialized, NORMAL_VARIABLE); |
@@ -5232,8 +5228,7 @@ |
target->statements()->Add(try_finally, zone()); |
} |
-void Parser::BuildIteratorCloseForCompletion(Scope* scope, |
- ZoneList<Statement*>* statements, |
+void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements, |
Variable* iterator, |
Expression* completion) { |
// |
@@ -5299,7 +5294,7 @@ |
Block* catch_block = factory()->NewBlock(nullptr, 0, false, nopos); |
- Scope* catch_scope = NewScopeWithParent(scope, CATCH_SCOPE); |
+ Scope* catch_scope = NewScope(CATCH_SCOPE); |
Variable* catch_variable = |
catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR, |
kCreatedInitialized, NORMAL_VARIABLE); |
@@ -5436,13 +5431,8 @@ |
Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos); |
try_block->statements()->Add(loop, zone()); |
- // The scope in which the parser creates this loop. |
- Scope* loop_scope = scope()->outer_scope(); |
- DCHECK_EQ(loop_scope->scope_type(), BLOCK_SCOPE); |
- DCHECK_EQ(scope()->scope_type(), BLOCK_SCOPE); |
- |
- FinalizeIteratorUse(loop_scope, var_completion, closing_condition, |
- loop->iterator(), try_block, final_loop); |
+ FinalizeIteratorUse(var_completion, closing_condition, loop->iterator(), |
+ try_block, final_loop); |
} |
return final_loop; |