Skip to content

Commit

Permalink
Set correct token position range for statement block containing moveN…
Browse files Browse the repository at this point in the history
…ext call of

for-in loops (second attempt at fixing #26941).

R=hausner@google.com

Review URL: https://codereview.chromium.org/2193113002 .
  • Loading branch information
crelier authored and whesse committed Aug 2, 2016
1 parent 8002734 commit 5a6de79
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions runtime/vm/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9015,13 +9015,18 @@ AstNode* Parser::ParseForInStatement(TokenPosition forin_pos,
loop_var_name = ExpectIdentifier("variable name expected");
}
ExpectToken(Token::kIN);

// Ensure that the block token range contains the call to moveNext and it
// also starts the block at a different token position than the following
// loop block. Both blocks can allocate contexts and if they have a matching
// token position range, it can be an issue (cf. bug 26941).
OpenBlock(); // Implicit block around while loop.

const TokenPosition collection_pos = TokenPos();
AstNode* collection_expr =
ParseAwaitableExpr(kAllowConst, kConsumeCascades, NULL);
ExpectToken(Token::kRPAREN);

OpenBlock(); // Implicit block around while loop.

// Generate implicit iterator variable and add to scope.
// We could set the type of the implicit iterator variable to Iterator<T>
// where T is the type of the for loop variable. However, the type error
Expand Down

0 comments on commit 5a6de79

Please sign in to comment.