Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 9113e8c7a4e3ba46b936b38d1f4627ff0c426cf4..108cca23d922e6a190a497d4d0058eb1353de82b 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -3794,17 +3794,25 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, |
| // Make a block around the statement in case a lexical binding |
| // is introduced, e.g. by a FunctionDeclaration. |
| + // This block must not be based on for_scope because if a lexical |
|
rossberg
2015/10/13 10:52:04
What does "be based on" mean?
Dan Ehrenberg
2015/10/13 14:58:40
Clarified wording
|
| + // binding is introduced which overlaps with the for-in/of, the |
| + // top level should actually point to the outer scope. |
| + Scope* body_scope = NewScope(for_scope, BLOCK_SCOPE); |
| + scope_ = body_scope; |
| Block* block = |
| factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); |
| Statement* body = ParseSubStatement(NULL, CHECK_OK); |
| block->statements()->Add(body, zone()); |
| InitializeForEachStatement(loop, expression, enumerable, block); |
| scope_ = saved_scope; |
| + body_scope->set_end_position(scanner()->location().end_pos); |
| + body_scope = body_scope->FinalizeBlockScope(); |
| + if (body_scope != nullptr) { |
| + block->set_scope(body_scope); |
| + } |
| for_scope->set_end_position(scanner()->location().end_pos); |
| for_scope = for_scope->FinalizeBlockScope(); |
| - if (for_scope != nullptr) { |
| - block->set_scope(for_scope); |
| - } |
| + DCHECK(for_scope == nullptr); |
| // Parsed for-in loop. |
| return loop; |