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

Unified Diff: src/parsing/preparser.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/parsing/parser-base.h ('k') | test/message/syntactic-tail-call-in-for-in.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/preparser.cc
diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
index f1ef8ab60b384b9adac6b9e7e17aec20d8589d0d..3f7adedd931c74fa475666f8ef2296ea76c4d99d 100644
--- a/src/parsing/preparser.cc
+++ b/src/parsing/preparser.cc
@@ -693,9 +693,10 @@ PreParser::Statement PreParser::ParseReturnStatement(bool* ok) {
tok != Token::EOS) {
ParseExpression(true, CHECK_OK);
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 Statement::Default();
}
@@ -850,7 +851,11 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
}
Expect(Token::RPAREN, CHECK_OK);
- ParseScopedStatement(true, CHECK_OK);
+ {
+ ReturnExprScope no_tail_calls(function_state_,
+ ReturnExprContext::kInsideForInOfBody);
+ ParseScopedStatement(true, CHECK_OK);
+ }
return Statement::Default();
}
} else {
@@ -953,7 +958,8 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
Expect(Token::TRY, CHECK_OK);
{
- DontCollectExpressionsInTailPositionScope no_tail_calls(function_state_);
+ ReturnExprScope no_tail_calls(function_state_,
+ ReturnExprContext::kInsideTryBlock);
ParseBlock(CHECK_OK);
}
« no previous file with comments | « src/parsing/parser-base.h ('k') | test/message/syntactic-tail-call-in-for-in.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698