fix: 块函数外层变量入口实例化为 undefined

This commit is contained in:
2026-09-18 01:15:11 +00:00
parent ac6a48412b
commit a8b4191d0f
3 changed files with 117 additions and 8 deletions
@@ -54,6 +54,18 @@ fn var_in_for_head_zero_iterations_read_is_undefined() {
truthy("function f(){ for (var x; false;) {} return typeof x } f() === 'undefined'");
}
#[test]
fn var_in_for_in_head_zero_iterations_read_is_undefined() {
// for-in 头 var 零迭代(空可迭代):入口实例化是唯一到达定义,读见 undefined。
truthy("function f(){ for (var x in {}) {} return typeof x } f() === 'undefined'");
}
#[test]
fn var_in_for_of_head_zero_iterations_read_is_undefined() {
// for-of 头 var 零迭代(空可迭代):入口实例化是唯一到达定义,读见 undefined。
truthy("function f(){ for (var x of []) {} return typeof x } f() === 'undefined'");
}
#[test]
fn multi_var_all_undefined() {
// 多 var 名每个槽都实例化(曾一名残留、一名 undefined)。