Represent nullable and union native contracts with traced alternatives

This commit is contained in:
2026-10-22 14:00:48 +08:00
parent 680caf81e3
commit 6b4cce1fee
12 changed files with 229 additions and 81 deletions
+11 -4
View File
@@ -313,14 +313,21 @@ impl Vm {
}
*executed += 1;
if let Some(signature) = self.objects.native_signature(function)?
&& !matches!(signature.returns, crate::AnnotationType::Any)
&& !signature.returns.is_any()
{
let check = NativeReturn {
name: self.object(function)?.payload().kind_name().into(),
expected: signature.returns,
};
if let Some(reference) = check.expected.reference() {
self.retain(reference)?;
let mut retained = Vec::new();
for reference in check.expected.references() {
if let Err(error) = self.retain(reference) {
for reference in retained {
self.release(reference)?;
}
return Err(error);
}
retained.push(reference);
}
returns.push(check);
}
@@ -363,7 +370,7 @@ impl Vm {
fn clear_native_returns(&mut self, returns: Vec<NativeReturn>) {
for check in returns {
if let Some(reference) = check.expected.reference() {
for reference in check.expected.references() {
self.release(reference)
.expect("native return check owns its type");
}