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; |
} |