Represent nullable and union native contracts with traced alternatives
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user