Validate unified source and native positional call contracts

This commit is contained in:
2026-10-22 12:02:41 +08:00
parent 20e29e3c5a
commit 44519abf7e
17 changed files with 331 additions and 28 deletions
+10
View File
@@ -260,6 +260,16 @@ impl Vm {
for argument in arguments {
self.validate_value(argument)?;
}
if let Some(arity) = self.objects.call_arity(function)?
&& !arity.accepts(arguments.len())
{
return Err(VmError::ArgumentCount {
name: self.object(function)?.payload().kind_name().into(),
required: arity.required,
maximum: arity.maximum,
provided: arguments.len(),
});
}
if let Some(callable) = self.object(function)?.payload().native_callable() {
return NativeContext::execute(&mut self.objects, function, arguments, callable);
}