fix: delete 真正删除属性(shape 链重建 + 数组元素 hole 标记)
字节码 delete 原先只清值为 undefined,属性残留在 shape 链,hasOwnProperty/ keys/枚举仍可见。统一走共享 delete_own_property(与 Reflect.deleteProperty 一致): - 命名属性经 shape 链重建移除,数组重建前保存并恢复元素区 - 数组下标元素标记为 hole(PropMetaEntry.hole),length 不变, 存在性检查(resolve_property/get_own_property_slot/ordinary_get/for-in) 判 hole,重赋值自动清除标记 - 不可配置属性统一返回 false(sloppy 语义,strict 抛错留待 emit 追踪严格模式) - set_or_create_prop_value 数组下标键路由元素区,修复 delete 后重赋值误入 shape 链 test262 Object +212 PASS/-102 FAIL,Array +149 PASS/-60 FAIL,无回归。
This commit is contained in:
@@ -663,7 +663,8 @@ impl Vm {
|
||||
}
|
||||
if obj.is_array() {
|
||||
if let Some(index) = self.array_index_from_property_key(prop_name_si) {
|
||||
if index < obj.prop_vec_len() as u32 {
|
||||
// 数组元素区:hole(删除标记)视为不存在。
|
||||
if index < obj.array_prop_count && !obj.prop_meta_at(index).is_some_and(|m| m.is_hole()) {
|
||||
return Some(obj.get_prop_at(index));
|
||||
}
|
||||
}
|
||||
@@ -701,7 +702,8 @@ impl Vm {
|
||||
}
|
||||
if obj.is_array() {
|
||||
if let Some(index) = self.array_index_from_property_key(prop_name_si) {
|
||||
if index < obj.prop_vec_len() as u32 {
|
||||
// 数组元素区:hole(删除标记)视为不存在。
|
||||
if index < obj.array_prop_count && !obj.prop_meta_at(index).is_some_and(|m| m.is_hole()) {
|
||||
return Some(index);
|
||||
}
|
||||
}
|
||||
@@ -1840,4 +1842,3 @@ mod tests {
|
||||
assert_eq!(vm.reg(255), JsValue::int(13));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user