| Index: src/parsing/parser.cc
|
| diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
|
| index 4973857c37ea0f2cf2854c35000be559db065e3a..b76822e19e1830a3db37bff41f6a8f56e5eca59e 100644
|
| --- a/src/parsing/parser.cc
|
| +++ b/src/parsing/parser.cc
|
| @@ -2661,15 +2661,22 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
|
|
|
| Expect(Token::RPAREN, CHECK_OK);
|
|
|
| - // For legacy compat reasons, give for loops similar treatment to
|
| - // if statements in allowing a function declaration for a body
|
| - Statement* body = ParseScopedStatement(NULL, true, CHECK_OK);
|
| - Statement* final_loop = InitializeForEachStatement(
|
| - loop, expression, enumerable, body, each_keyword_position);
|
| + {
|
| + ReturnExprScope no_tail_calls(function_state_,
|
| + ReturnExprContext::kInsideForInOfBody);
|
| + BlockState block_state(&scope_state_);
|
| + block_state.set_start_position(scanner()->location().beg_pos);
|
|
|
| - DCHECK_NULL(for_state.FinalizedBlockScope());
|
| - return final_loop;
|
| + // For legacy compat reasons, give for loops similar treatment to
|
| + // if statements in allowing a function declaration for a body
|
| + Statement* body = ParseScopedStatement(NULL, true, CHECK_OK);
|
| + block_state.set_end_position(scanner()->location().end_pos);
|
| + Statement* final_loop = InitializeForEachStatement(
|
| + loop, expression, enumerable, body, each_keyword_position);
|
|
|
| + DCHECK_NULL(for_state.FinalizedBlockScope());
|
| + return final_loop;
|
| + }
|
| } else {
|
| init = factory()->NewExpressionStatement(expression, lhs_beg_pos);
|
| }
|
|
|