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

Unified Diff: src/parsing/pattern-rewriter.cc

Issue 2520883002: [parser] Fix scopes in rewriting of for-of and destructuring assignments. (Closed)
Patch Set: Take into account that the scope may have been removed when we get to rewrite. Created 4 years, 1 month 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
Index: src/parsing/pattern-rewriter.cc
diff --git a/src/parsing/pattern-rewriter.cc b/src/parsing/pattern-rewriter.cc
index 21b1cec69655c092b3c4e822ed3d14dd6987ccb6..217b8da08532df9b6413698bdbebf2689a92787f 100644
--- a/src/parsing/pattern-rewriter.cc
+++ b/src/parsing/pattern-rewriter.cc
@@ -586,8 +586,18 @@ void Parser::PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
Expression* closing_condition = factory()->NewUnaryOperation(
Token::NOT, factory()->NewVariableProxy(done), nopos);
- parser_->FinalizeIteratorUse(completion, closing_condition, iterator, block_,
- target);
+
+ // Since assignments are being rewritten at the end of parsing, scope() may
+ // already have been removed by FinalizeBlockScope in the meantime. In that
+ // case, find the first outer non-removed scope.
Dan Ehrenberg 2016/11/22 16:07:00 Should we put this logic to find the appropriate n
neis 2016/11/23 12:51:08 Done.
+ Scope* real_scope = scope();
+ while (real_scope != nullptr && real_scope->HasBeenRemoved()) {
+ real_scope = real_scope->outer_scope();
+ }
+ DCHECK_NOT_NULL(real_scope);
Toon Verwaest 2016/11/22 08:30:18 What about moving this into an aptly named helper
neis 2016/11/23 12:51:08 Done.
+
+ parser_->FinalizeIteratorUse(real_scope, completion, closing_condition,
+ iterator, block_, target);
block_ = target;
}

Powered by Google App Engine
This is Rietveld 408576698