fix: for-in 右值原始值装箱后枚举

This commit is contained in:
2026-09-25 17:11:14 +00:00
parent 53b16537bc
commit 2643e500d4
4 changed files with 39 additions and 14 deletions
+3 -3
View File
@@ -177,9 +177,9 @@ fn eval_for_in_empty_object() {
}
#[test]
fn eval_for_in_non_object_throws() {
let result = eval("for (k in 42) {}");
assert!(result.contains("TypeError"), "expected TypeError, got: {result}");
fn eval_for_in_primitive_number() {
// 右值经 ToObject 装箱后枚举:数字盒无自身可枚举属性,空枚举。
assert_eq!(eval("var n=0; for (k in 42) { n=n+1; } n"), "0");
}
#[test]