fix: 数值长度数组构造建 n 个空洞

This commit is contained in:
2026-09-19 10:59:36 +00:00
parent a953652da8
commit 6610384d90
2 changed files with 43 additions and 0 deletions
+7
View File
@@ -26,6 +26,13 @@ pub fn array_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
Err(err) => return NativeResult::Err(err),
};
let arr = vm.alloc_object(JsObject::new_array(EMPTY_SHAPE_ID, proto_val, n, vm.epoch().bump()));
// 数值长度分支建 n 个空洞而非 present-undefined:`in`、for-in、
// Object.keys 按缺失处理,元素 Get 落原型链。
for i in 0..n {
unsafe {
(*arr).mark_hole_at(i);
}
}
return NativeResult::Ok(JsValue::from_js_object(arr));
}
}