fix: native 调用保存/恢复 this 寄存器,避免方法内调用后 this 被 callee 覆盖

This commit is contained in:
爱特每羊队
2026-06-30 16:12:42 +08:00
parent 05b149b275
commit b797dcdec0
2 changed files with 21 additions and 4 deletions
+11
View File
@@ -341,3 +341,14 @@ fn private_class_same_name_different_classes_do_not_share_brand() {
.unwrap();
assert!(result.is_bool() && result.as_bool());
}
#[test]
fn this_survives_native_call_inside_method() {
let mut vm = Vm::new();
let result = eval(
&mut vm,
"class C { v=7; m(){ Object.keys(this); Object.getOwnPropertyNames(this); return this.v; } } new C().m()",
)
.unwrap();
assert_eq!(result.as_int(), 7);
}