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

Unified Diff: src/parsing/parser-base.h

Issue 1955393002: [es8] Throw SyntaxError when tail call expressions occur in non-strict mode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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') | test/message/syntactic-tail-call-in-binop-lhs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index 484d4b977e04c66bd26d3b42d860e00195fd6802..89b5b10da965e0068fbfc66c42a30c2c4fd3e4ba 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -2228,6 +2228,17 @@ ParserBase<Traits>::ParseTailCallExpression(ExpressionClassifier* classifier,
CheckNoTailCallExpressions(classifier, CHECK_OK);
Scanner::Location loc(pos, scanner()->location().end_pos);
+ if (!expression->IsCall()) {
+ Scanner::Location sub_loc(sub_expression_pos, loc.end_pos);
+ ReportMessageAt(sub_loc, MessageTemplate::kUnexpectedInsideTailCall);
+ *ok = false;
+ return Traits::EmptyExpression();
+ }
+ if (!is_strict(language_mode())) {
+ ReportMessageAt(loc, MessageTemplate::kUnexpectedSloppyTailCall);
+ *ok = false;
+ return Traits::EmptyExpression();
+ }
ReturnExprContext return_expr_context =
function_state_->return_expr_context();
if (return_expr_context != ReturnExprContext::kInsideValidReturnStatement) {
@@ -2250,12 +2261,6 @@ ParserBase<Traits>::ParseTailCallExpression(ExpressionClassifier* classifier,
*ok = false;
return Traits::EmptyExpression();
}
- if (!expression->IsCall()) {
- Scanner::Location sub_loc(sub_expression_pos, loc.end_pos);
- ReportMessageAt(sub_loc, MessageTemplate::kUnexpectedInsideTailCall);
- *ok = false;
- return Traits::EmptyExpression();
- }
classifier->RecordTailCallExpressionError(
loc, MessageTemplate::kUnexpectedTailCall);
function_state_->AddExpressionInTailPosition(expression, loc);
« no previous file with comments | « src/messages.h ('k') | test/message/syntactic-tail-call-in-binop-lhs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698