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

Unified Diff: src/preparser.cc

Issue 1290193003: Align PreParser for loop early error-checking with Parser (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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/message/for-loop-invalid-lhs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/preparser.cc
diff --git a/src/preparser.cc b/src/preparser.cc
index f186f8a694927d1808d48167b4de31340973c9d1..9a30ca58cc71b18031b17ff9cd152e95826a50f1 100644
--- a/src/preparser.cc
+++ b/src/preparser.cc
@@ -913,13 +913,16 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
return Statement::Default();
}
} else {
+ int lhs_beg_pos = peek_position();
Expression lhs = ParseExpression(false, CHECK_OK);
+ int lhs_end_pos = scanner()->location().end_pos;
is_let_identifier_expression =
lhs.IsIdentifier() && lhs.AsIdentifier().IsLet();
if (CheckInOrOf(lhs.IsIdentifier(), &mode, ok)) {
if (!*ok) return Statement::Default();
- // TODO(adamk): Should call CheckAndRewriteReferenceExpression here
- // to catch early errors if lhs is not a valid reference expression.
+ lhs = CheckAndRewriteReferenceExpression(
+ lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
+ CHECK_OK);
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK);
« no previous file with comments | « no previous file | test/message/for-loop-invalid-lhs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698