Add explicit managed traits and inherited method arity contracts

This commit is contained in:
2026-10-21 21:34:46 +08:00
parent b7daabdaad
commit eb60212428
16 changed files with 454 additions and 16 deletions
+10
View File
@@ -13,6 +13,11 @@ pub enum VmError {
UnsupportedOperation(&'static str),
InvalidArgument(&'static str),
ObjectKindMismatch(&'static str),
TraitViolation {
capability: String,
method: String,
reason: &'static str,
},
EmptyCell,
InvalidBytecode {
offset: usize,
@@ -43,6 +48,11 @@ impl fmt::Display for VmError {
}
Self::InvalidArgument(message) => f.write_str(message),
Self::ObjectKindMismatch(expected) => write!(f, "expected {expected} object"),
Self::TraitViolation {
capability,
method,
reason,
} => write!(f, "trait {capability} method {method}: {reason}"),
Self::EmptyCell => f.write_str("cell is empty"),
Self::InvalidBytecode { offset, reason } => {
write!(f, "invalid bytecode at code unit {offset}: {reason}")