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

Unified Diff: src/parsing/parser.cc

Issue 1914423002: [es8] Report proper syntax error for tail call expressions in for-in and for-of bodies. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@tco-fix
Patch Set: Addressing comments Created 4 years, 8 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 | « src/messages.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
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 3549cca365e8f77393a38ca0c3aea39daed8e112..dfd599f014711f6947b9f716539aa39d2365fffc 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2639,9 +2639,10 @@ Statement* Parser::ParseReturnStatement(bool* ok) {
// TODO(ishell): update chapter number.
// ES8 XX.YY.ZZ
if (tail_call_position >= 0) {
- if (!function_state_->collect_expressions_in_tail_position()) {
- Scanner::Location loc(tail_call_position, tail_call_position + 1);
- ReportMessageAt(loc, MessageTemplate::kTailCallInTryBlock);
+ ReturnExprContext return_expr_context =
+ function_state_->return_expr_context();
+ if (return_expr_context != ReturnExprContext::kNormal) {
+ ReportIllegalTailCallAt(tail_call_position, return_expr_context);
*ok = false;
return NULL;
}
@@ -2848,7 +2849,8 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
Block* try_block;
{
- DontCollectExpressionsInTailPositionScope no_tail_calls(function_state_);
+ ReturnExprScope no_tail_calls(function_state_,
+ ReturnExprContext::kInsideTryBlock);
try_block = ParseBlock(NULL, CHECK_OK);
}
@@ -3555,8 +3557,8 @@ Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
factory()->NewBlock(NULL, 3, false, RelocInfo::kNoPosition);
{
- DontCollectExpressionsInTailPositionScope no_tail_calls(
- function_state_);
+ ReturnExprScope no_tail_calls(function_state_,
+ ReturnExprContext::kInsideForInOfBody);
BlockState block_state(&scope_, body_scope);
Statement* body = ParseScopedStatement(NULL, true, CHECK_OK);
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698