Commit 3ef9af84 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Don't hoist sloppy block functions on error

Bug: chromium:926819
Change-Id: I44832f8707c413d40e5632ed39b97624059f1fba
Reviewed-on: https://chromium-review.googlesource.com/c/1445891Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59198}
parent 518a39dd
...@@ -176,24 +176,27 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -176,24 +176,27 @@ PreParser::PreParseResult PreParser::PreParseFunction(
bool allow_duplicate_parameters = false; bool allow_duplicate_parameters = false;
CheckConflictingVarDeclarations(inner_scope); CheckConflictingVarDeclarations(inner_scope);
if (formals.is_simple) { if (!has_error()) {
if (is_sloppy(function_scope->language_mode())) { if (formals.is_simple) {
function_scope->HoistSloppyBlockFunctions(nullptr); if (is_sloppy(function_scope->language_mode())) {
} function_scope->HoistSloppyBlockFunctions(nullptr);
}
allow_duplicate_parameters = allow_duplicate_parameters =
is_sloppy(function_scope->language_mode()) && !IsConciseMethod(kind); is_sloppy(function_scope->language_mode()) && !IsConciseMethod(kind);
} else { } else {
if (is_sloppy(inner_scope->language_mode())) { if (is_sloppy(inner_scope->language_mode())) {
inner_scope->HoistSloppyBlockFunctions(nullptr); inner_scope->HoistSloppyBlockFunctions(nullptr);
} }
SetLanguageMode(function_scope, inner_scope->language_mode()); SetLanguageMode(function_scope, inner_scope->language_mode());
inner_scope->set_end_position(scanner()->peek_location().end_pos); inner_scope->set_end_position(scanner()->peek_location().end_pos);
if (inner_scope->FinalizeBlockScope() != nullptr) { if (inner_scope->FinalizeBlockScope() != nullptr) {
const AstRawString* conflict = inner_scope->FindVariableDeclaredIn( const AstRawString* conflict = inner_scope->FindVariableDeclaredIn(
function_scope, VariableMode::kLastLexicalVariableMode); function_scope, VariableMode::kLastLexicalVariableMode);
if (conflict != nullptr) ReportVarRedeclarationIn(conflict, inner_scope); if (conflict != nullptr)
ReportVarRedeclarationIn(conflict, inner_scope);
}
} }
} }
......
// 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.
assertThrows("a(function(){{let f;function f}})", SyntaxError);
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