Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: runtime/vm/parser.cc

Issue 2193113002: Set correct token position range for statement block containing moveNext call of (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add comment Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc
index 9369b9055ea8616c3874fada6c99025c77d7146e..d11536b775f48a4432b98e5783fd348e6293a117 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698