From 41d114bd5a51483747eb09e90524f03057096b38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=89=B9=E6=AF=8F=E7=BE=8A=E9=98=9F?= Date: Wed, 10 Jun 2026 19:51:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20SUPER=5FCALL=20?= =?UTF-8?q?=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_vm/src/vm.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/oxide_vm/src/vm.rs b/crates/oxide_vm/src/vm.rs index 2057b14..3cab140 100644 --- a/crates/oxide_vm/src/vm.rs +++ b/crates/oxide_vm/src/vm.rs @@ -1605,6 +1605,7 @@ impl Vm { if super_obj.native_fn().is_some() { self.regs[253] = derived_this; + self.regs[254] = super_ctor; // bind_dispatcher reads regs[254] as the wrapper callee let (args_buf, len) = Self::build_native_args(first_arg_reg, arg_count, 253); // SAFETY: native_fn was set via set_native_fn with a valid NativeFn pointer; // native_fn_ptr_to_fn is the single coercion point for NativeFnPtr → NativeFn. @@ -1622,8 +1623,16 @@ impl Vm { Err(e) => return Err(e), } } - NativeResult::TailCall { .. } => { - throw_err!(self, TypeError, "super constructor tail call not supported"); + NativeResult::TailCall { callee, this, args } => { + // e.g. bound function: resolve the tail call, use its return + // value as the constructed instance (or fall back to derived_this). + match self.call_function_sync(callee, this, &args) { + Ok(val) => { + self.regs[254] = if val.is_object() { val } else { derived_this }; + self.regs[rd] = self.regs[254]; + } + Err(e) => return Err(e), + } } } } else if super_obj.sub_module_index() > 0 {