Commit 092b4317 authored by adamk's avatar adamk Committed by Commit bot

Align PreParser for loop early error-checking with Parser

R=rossberg@chromium.org

Review URL: https://codereview.chromium.org/1290193003

Cr-Commit-Position: refs/heads/master@{#30168}
parent 05849031
...@@ -913,13 +913,16 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) { ...@@ -913,13 +913,16 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
return Statement::Default(); return Statement::Default();
} }
} else { } else {
int lhs_beg_pos = peek_position();
Expression lhs = ParseExpression(false, CHECK_OK); Expression lhs = ParseExpression(false, CHECK_OK);
int lhs_end_pos = scanner()->location().end_pos;
is_let_identifier_expression = is_let_identifier_expression =
lhs.IsIdentifier() && lhs.AsIdentifier().IsLet(); lhs.IsIdentifier() && lhs.AsIdentifier().IsLet();
if (CheckInOrOf(lhs.IsIdentifier(), &mode, ok)) { if (CheckInOrOf(lhs.IsIdentifier(), &mode, ok)) {
if (!*ok) return Statement::Default(); if (!*ok) return Statement::Default();
// TODO(adamk): Should call CheckAndRewriteReferenceExpression here lhs = CheckAndRewriteReferenceExpression(
// to catch early errors if lhs is not a valid reference expression. lhs, lhs_beg_pos, lhs_end_pos, MessageTemplate::kInvalidLhsInFor,
CHECK_OK);
ParseExpression(true, CHECK_OK); ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
ParseSubStatement(CHECK_OK); ParseSubStatement(CHECK_OK);
......
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// TODO(adamk): Remove flag after the test runner tests all message tests with
// the preparser: https://code.google.com/p/v8/issues/detail?id=4372
// Flags: --min-preparse-length=0
function f() { for ("unassignable" in {}); }
*%(basename)s:9: ReferenceError: Invalid left-hand side in for-loop
function f() { for ("unassignable" in {}); }
^^^^^^^^^^^^^^
ReferenceError: Invalid left-hand side in for-loop
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment