v8/test/mjsunit/regress/regress-crbug-1074737.js
Toon Verwaest f5818c6b7b [parser] Treat var initializers in masking catch as assigning
This changes the existing implementation that creates an unresolved reference for those cases to look at exactly what scopes are relevant so it can correctly handle catch scopes and avoid re-resolving later.

Variable through with aren't marked as assigning since this information isn't relevant for the with itself; and if the with is passed through, there's no need to mark the outer variable as assigned since it's either initialized or it isn't.

The catch variable is assigned since it is relevant for the catch variable.

The CL uses LookupLocal which wouldn't work for deserialized scopes, but this isn't relevant because 1) eval scopes are declaration scopes, and 2) eval causes all outer variables to be maybe_assigned anyway.

Bug: chromium:1074737
Change-Id: I3febca479ddd1f3c62eae299190b06c0b4cd3746
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2187272
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67683}
2020-05-08 14:25:50 +00:00

41 lines
855 B
JavaScript

// 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: --allow-natives-syntax
try {
throw 42
} catch (e) {
function foo() { return e };
%PrepareFunctionForOptimization(foo);
%OptimizeFunctionOnNextCall(foo);
foo();
var e = "expected";
}
assertEquals("expected", foo());
try {
throw 42
} catch (f) {
function foo2() { return f };
%PrepareFunctionForOptimization(foo2);
%OptimizeFunctionOnNextCall(foo2);
foo2();
with ({}) {
var f = "expected";
}
}
assertEquals("expected", foo2());
(function () {
function foo3() { return g };
%PrepareFunctionForOptimization(foo3);
%OptimizeFunctionOnNextCall(foo3);
foo3();
with ({}) {
var g = "expected";
}
assertEquals("expected", foo3());
})()