fix: native 构造器可构造性标志(OBJ_TYPE_CONSTRUCTOR)+ Reflect.construct/new 校验

This commit is contained in:
2026-08-07 20:44:04 +08:00
parent 4768e92ba8
commit 0df0c2cb98
4 changed files with 15 additions and 0 deletions
+6
View File
@@ -35,6 +35,12 @@ impl Vm {
.raise_type_error("arrow functions cannot be used as constructors")
.map(|_| true);
}
// native 方法(非构造器)不可 new。
if ctor_obj.native_fn().is_some() && ctor_obj.type_tag != oxide_types::object::JsObject::OBJ_TYPE_CONSTRUCTOR {
return self
.raise_type_error("object is not a constructor")
.map(|_| true);
}
let ext = self.bytecode[self.pc];
self.pc += 1;