[parser] Don't re-preparse when trying to find an unidentifiable error

Bug: chromium:907669
Change-Id: I7633780b1f3a1a290593818a3e558c5a1bb81502
Reviewed-on: https://chromium-review.googlesource.com/c/1347486
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57735}
This commit is contained in:
Toon Verwaest 2018-11-22 13:20:38 +01:00 committed by Commit Bot
parent 948cf2f642
commit 23e99a95a1
3 changed files with 14 additions and 2 deletions

View File

@ -1717,8 +1717,11 @@ ParserBase<Impl>::ParsePrimaryExpression() {
if (Check(Token::RPAREN)) {
// ()=>x. The continuation that consumes the => is in
// ParseAssignmentExpression.
if (peek() != Token::ARROW) ReportUnexpectedToken(Token::RPAREN);
next_arrow_formals_parenthesized_ = true;
if (peek() == Token::ARROW) {
next_arrow_formals_parenthesized_ = true;
} else {
ReportUnexpectedToken(Token::RPAREN);
}
return factory()->NewEmptyParentheses(beg_pos);
}
// Heuristically try to detect immediately called functions before

View File

@ -2710,6 +2710,10 @@ bool Parser::SkipFunction(
// Propagate stack overflow.
set_stack_overflow();
} else if (pending_error_handler()->has_error_unidentifiable_by_preparser()) {
// Make sure we don't re-preparse inner functions of the aborted function.
// The error might be in an inner function.
allow_lazy_ = false;
mode_ = PARSE_EAGERLY;
DCHECK(!pending_error_handler()->stack_overflow());
// If we encounter an error that the preparser can not identify we reset to
// the state before preparsing. The caller may then fully parse the function

View File

@ -0,0 +1,5 @@
// Copyright 2018 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.
assertThrows("function f() { function g() { (); ", SyntaxError);