v8/test/mjsunit/regress-v8-13459.js
yangwenming 7df371b2d5 [parser] Avoid function declarations being covered.
In some cases, a declaration of a function may be covered by
variables with a same name and thus bound to one parameter. This
CL records variables which should not be bound to the parameter,
are skipped when inserting shadowing variable binding initilizers.

Bug: v8:13459
Change-Id: Id7d147392450b177d219bfd04245b47d9e58c20e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4130416
Reviewed-by: Marja Hölttä <marja@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85321}
2023-01-16 14:11:43 +00:00

112 lines
1.5 KiB
JavaScript

// Copyright 2023 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.
// For rest parameters.
function f1(...x) {
{ var x; }
function x(){}
assertEquals('function', typeof x);
var x = 10;
assertEquals(10, x);
};
f1(0);
function f2(...x) {
var x;
function x(){}
assertEquals('function', typeof x);
var x = 10;
assertEquals(10, x);
};
f2(0);
function f3(...x) {
var x;
assertEquals('object', typeof x);
}
f3(1);
function f4(...x) {
var x = 10;
assertEquals(10, x);
}
f4(1);
function f5(...x) {
function x(){}
assertEquals('function', typeof x);
}
f5(1);
// For simple parameters.
function f6(x) {
var x = 10;
function x(){}
assertEquals(10, x);
}
f6(1);
function f7(x) {
var x;
function x(){}
assertEquals('function', typeof x);
}
f7(1);
function f8(x) {
var x;
assertEquals(1, x);
}
f8(1);
function f9(x) {
var x = 10;
assertEquals(10, x);
}
f9(1);
function f10(x) {
function x(){}
assertEquals('function', typeof x);
}
f10(1);
// For default parameters.
function f11(x = 2) {
var x;
function x(){}
assertEquals('function', typeof x);
}
f11();
f11(1);
function f12(x = 2) {
var x;
function x(){}
assertEquals('function', typeof x);
var x = 10;
assertEquals(10, x);
}
f12();
f12(1);
function f13(x = 2) {
var x;
assertEquals(2, x);
}
f13();
function f14(x = 2) {
var x = 1;
assertEquals(1, x);
}
f14();
f14(3);
function f15(x = 2) {
function x(){}
assertEquals('function', typeof x);
}
f15();