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

Unified Diff: src/parsing/parser.cc

Issue 2343823002: [parser] Fix tail calls in for in/of loops (Closed)
Patch Set: Created 4 years, 3 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 | test/mjsunit/es6/tail-call.js » ('j') | test/mjsunit/es6/tail-call.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « no previous file | test/mjsunit/es6/tail-call.js » ('j') | test/mjsunit/es6/tail-call.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698