From 92cd4d1ea2cb7b0bd5d881175712e923c8f9d6b9 Mon Sep 17 00:00:00 2001 From: Dan Elphick Date: Thu, 18 Jun 2020 16:43:44 +0100 Subject: [PATCH] [parser] Don't mark sloppy block functions as assigned When preparsing and detecting a sloppy block function redefinition then don't mark the variable as assigned to make it consistent with the eager parser. Bug: chromium:1053364 Change-Id: Iec7c24db80014bfe73ee41a4f3bb7a41a354cef2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2241511 Auto-Submit: Dan Elphick Reviewed-by: Toon Verwaest Commit-Queue: Dan Elphick Cr-Commit-Position: refs/heads/master@{#68415} --- src/parsing/preparser.cc | 4 ---- test/mjsunit/regress/regress-crbug-1053364.js | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 test/mjsunit/regress/regress-crbug-1053364.js diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc index f9af109d81..8b68f62c94 100644 --- a/src/parsing/preparser.cc +++ b/src/parsing/preparser.cc @@ -325,10 +325,6 @@ PreParser::Expression PreParser::ParseFunctionLiteral( // Parsing the body may change the language mode in our scope. language_mode = function_scope->language_mode(); - if (is_sloppy(language_mode)) { - function_scope->HoistSloppyBlockFunctions(nullptr); - } - // Validate name and parameter names. We can do this only after parsing the // function, since the function can declare itself strict. CheckFunctionName(language_mode, function_name, function_name_validity, diff --git a/test/mjsunit/regress/regress-crbug-1053364.js b/test/mjsunit/regress/regress-crbug-1053364.js new file mode 100644 index 0000000000..5f69cd000c --- /dev/null +++ b/test/mjsunit/regress/regress-crbug-1053364.js @@ -0,0 +1,20 @@ +// Copyright 2020 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. + +// Flags: --throws + +function main() { + function g() { + function h() { + f; + } + { + function f() {} + } + f; + throw new Error(); + } + g(); +} +main();