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
+3 -10
View File
@@ -13,19 +13,12 @@ pub(crate) enum StackEntry {
#[derive(Debug)]
pub(crate) struct NativeReturn {
pub name: String,
pub expected: crate::AnnotationType,
pub expected: crate::CallType,
}
impl NativeReturn {
pub fn check(&self, store: &objects::ObjectStore, value: &Value) -> Result<(), crate::VmError> {
if !store.matches_annotation(value, self.expected)? {
return Err(crate::VmError::TypeMismatch {
function: self.name.clone(),
position: "return".into(),
expected: store.annotation_type_name(self.expected)?,
actual: store.value_type_name(value)?,
});
}
Ok(())
self.expected
.check(store, &self.name, "return".into(), value)
}
}