Classify read-only wrappers with dynamic delegated effects
This commit is contained in:
@@ -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",
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user