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

Unified Diff: runtime/vm/parser.cc

Issue 2075813003: Allow rethrow in nested try statements (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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_26530_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 51d807f2915f60aa044be6966027a14bcea84979..5f95f352541511b4efafc4fe523882e4e72b7547 100644
--- a/runtime/vm/parser.cc
+++ b/runtime/vm/parser.cc
@@ -10236,8 +10236,13 @@ AstNode* Parser::ParseStatement() {
// Rethrow of current exception.
ConsumeToken();
ExpectSemicolon();
- // Check if it is ok to do a rethrow.
- if ((try_stack_ == NULL) || !try_stack_->inside_catch()) {
+ // Check if it is ok to do a rethrow. Find the inntermost enclosing
+ // catch block.
+ TryStack* try_statement = try_stack_;
+ while ((try_statement != NULL) && !try_statement->inside_catch()) {
+ try_statement = try_statement->outer_try();
+ }
+ if (try_statement == NULL) {
ReportError(statement_pos, "rethrow of an exception is not valid here");
}
@@ -10245,7 +10250,7 @@ AstNode* Parser::ParseStatement() {
// instead of :exception_var and :stack_trace_var.
// These variables are bound in the block containing the try.
// Look in the try scope directly.
- LocalScope* scope = try_stack_->try_block()->scope->parent();
+ LocalScope* scope = try_statement->try_block()->scope->parent();
ASSERT(scope != NULL);
LocalVariable* excp_var;
LocalVariable* trace_var;
« no previous file with comments | « no previous file | tests/language/regress_26530_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698