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

Unified Diff: runtime/vm/parser.cc

Issue 1661433003: Restore try contexts when breaking out of async for loops (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Add regression test Created 4 years, 11 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 | tests/language/regress_24935_test.dart » ('j') | 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 2034a2f5f428b34d39749c265bac7c6343feacc0..bed681e8ae70aaf8af2e1dbe44b39912cefe4eec 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -8719,7 +8719,7 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) {
outer_try->try_index() : CatchClauseNode::kInvalidTryIndex;
// The finally block contains a call to cancel the stream.
- // :for-in-iter.cancel()
+ // :for-in-iter.cancel();
// Inline the finally block to the exit points in the try block.
intptr_t node_index = 0;
@@ -8729,6 +8729,17 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) {
}
do {
OpenBlock();
+
+ // Restore the saved try context of the enclosing try block if one
+ // exists.
+ if (outer_saved_try_ctx != NULL) {
+ current_block_->statements->Add(new (Z) StoreLocalNode(
+ TokenPosition::kNoSource,
+ outer_saved_try_ctx,
+ new (Z) LoadLocalNode(TokenPosition::kNoSource,
+ outer_async_saved_try_ctx)));
+ }
+ // :for-in-iter.cancel();
ArgumentListNode* no_args =
new(Z) ArgumentListNode(TokenPosition::kNoSource);
current_block_->statements->Add(
@@ -8737,6 +8748,7 @@ AstNode* Parser::ParseAwaitForStatement(String* label_name) {
Symbols::Cancel(),
no_args));
finally_clause = CloseBlock();
+
AstNode* node_to_inline = try_statement->GetNodeToInlineFinally(node_index);
if (node_to_inline != NULL) {
InlinedFinallyNode* node =
@@ -9127,7 +9139,7 @@ SequenceNode* Parser::EnsureFinallyClause(
if (try_stack_ != NULL) {
try_stack_->enter_finally();
}
- // In case of async closures we need to restore the saved try index of an
+ // In case of async closures we need to restore the saved try context of an
// outer try block (if it exists). The current try block has already been
// removed from the stack of try blocks.
if (is_async) {
« no previous file with comments | « no previous file | tests/language/regress_24935_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698