fix: preserve plain reference rebinding during read-only calls

This commit is contained in:
2026-10-21 14:30:06 +08:00
parent ff49f266a2
commit 4a2f81cb48
9 changed files with 51 additions and 2 deletions
+13
View File
@@ -120,6 +120,13 @@ pub trait ObjectPayload: Any + fmt::Debug + Send + Sync {
/// object identity after replacing its host-owned target. Ordinary payloads
/// return false and retain normal value assignment. Implementations must
/// validate before mutation and must not add untraced managed-object edges.
/// True only when legacy assign_from always returns false. Read-only
/// callers can then rebind a local reference without attempting mutation.
/// assignment_cell is checked first and remains a protected write protocol.
fn reference_assignment_only(&self) -> bool {
false
}
fn assign_from(&self, _source: &dyn ObjectPayload) -> Result<bool, VmError> {
Ok(false)
}
@@ -141,6 +148,9 @@ pub trait ObjectPayload: Any + fmt::Debug + Send + Sync {
pub struct Record;
impl ObjectPayload for Record {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn Any {
self
}
@@ -180,6 +190,9 @@ impl EndorNativeFunctionObject {
pub type NativeFunction = EndorNativeFunctionObject;
impl ObjectPayload for EndorNativeFunctionObject {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn Any {
self
}