Classify read-only wrappers with dynamic delegated effects

This commit is contained in:
2026-10-22 15:07:50 +08:00
parent 100bf637f9
commit c96dce118b
9 changed files with 89 additions and 10 deletions
+6 -1
View File
@@ -55,6 +55,9 @@ impl CallArity {
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CallEffect {
ReadOnly,
/// The native body itself is read-only; delegated effects are dynamic and
/// checked by the VM in the same execution/heap scope.
Delegated,
Mutating,
External,
}
@@ -192,7 +195,9 @@ impl CallSignature {
) -> Result<(), VmError> {
self.validate(store)?;
self.arity.check(name.into(), arguments.len())?;
if store.is_read_only() && self.effect != CallEffect::ReadOnly {
if store.is_read_only()
&& !matches!(self.effect, CallEffect::ReadOnly | CallEffect::Delegated)
{
return Err(VmError::InvalidArgument(
"native effect is forbidden during read-only execution",
));