Index: src/parsing/parser.cc |
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc |
index 0f80ec66f157880404dbf89691cc0075420c3050..27b1d4b81dd25c4663468a65fe0a665e8f8ac5b1 100644 |
--- a/src/parsing/parser.cc |
+++ b/src/parsing/parser.cc |
@@ -2196,7 +2196,8 @@ Statement* Parser::ParseClassDeclaration(ZoneList<const AstRawString*>* names, |
} |
-Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
+Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, |
+ bool finalize_block_scope, bool* ok) { |
// The harmony mode uses block elements instead of statements. |
// |
// Block :: |
@@ -2222,12 +2223,19 @@ Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
} |
Expect(Token::RBRACE, CHECK_OK); |
block_scope->set_end_position(scanner()->location().end_pos); |
- block_scope = block_scope->FinalizeBlockScope(); |
+ if (finalize_block_scope) { |
+ block_scope = block_scope->FinalizeBlockScope(); |
+ } |
body->set_scope(block_scope); |
return body; |
} |
+Block* Parser::ParseBlock(ZoneList<const AstRawString*>* labels, bool* ok) { |
+ return ParseBlock(labels, true, ok); |
+} |
+ |
+ |
Block* Parser::DeclarationParsingResult::BuildInitializationBlock( |
ZoneList<const AstRawString*>* names, bool* ok) { |
Block* result = descriptor.parser->factory()->NewBlock( |
@@ -3992,12 +4000,13 @@ DoExpression* Parser::ParseDoExpression(bool* ok) { |
Expect(Token::DO, CHECK_OK); |
Variable* result = |
scope_->NewTemporary(ast_value_factory()->dot_result_string()); |
- Block* block = ParseBlock(nullptr, CHECK_OK); |
+ Block* block = ParseBlock(nullptr, false, CHECK_OK); |
DoExpression* expr = factory()->NewDoExpression(block, result, pos); |
if (!Rewriter::Rewrite(this, expr, ast_value_factory())) { |
*ok = false; |
return nullptr; |
} |
+ block->set_scope(block->scope()->FinalizeBlockScope()); |
return expr; |
} |