Skip to content

Commit 478e0db

Browse files
committed
Eliminate remaining case of ambiguous context level info
When generating the scopes in an await-for loop, make sure the scope of the loop block is a proper sub-range of the block surrounding the loop. This eliminates the last case where the compiler generated context info of the same range, but with contradicting context level info. BUG=26941 [email protected] Review URL: https://codereview.chromium.org/2201203002 .
1 parent bd79732 commit 478e0db

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

runtime/vm/parser.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8724,16 +8724,20 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) {
87248724

87258725
// Parse stream expression.
87268726
ExpectToken(Token::kIN);
8727+
8728+
// Open a block for the iterator variable and the try-finally statement
8729+
// that contains the loop. Ensure that the block starts at a different
8730+
// token position than the following loop block. Both blocks can allocate
8731+
// contexts and if they have a matching token position range,
8732+
// it can be an issue (cf. bug 26941).
8733+
OpenBlock();
8734+
const Block* await_for_block = current_block_;
8735+
87278736
const TokenPosition stream_expr_pos = TokenPos();
87288737
AstNode* stream_expr =
87298738
ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
87308739
ExpectToken(Token::kRPAREN);
87318740

8732-
// Open a block for the iterator variable and the try-finally
8733-
// statement that contains the loop.
8734-
OpenBlock();
8735-
const Block* loop_block = current_block_;
8736-
87378741
// Build creation of implicit StreamIterator.
87388742
// var :for-in-iter = new StreamIterator(stream_expr).
87398743
const Class& stream_iterator_cls =
@@ -8983,8 +8987,8 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) {
89838987
try_index,
89848988
finally_clause);
89858989

8986-
ASSERT(current_block_ == loop_block);
8987-
loop_block->statements->Add(try_catch_node);
8990+
ASSERT(current_block_ == await_for_block);
8991+
await_for_block->statements->Add(try_catch_node);
89888992

89898993
return CloseBlock(); // Implicit block around while loop.
89908994
}

0 commit comments

Comments
 (0)