fix: allow plain local reference rebinding in source paint
Verify Tessera GUI / verify (push) Failing after 7m30s

This commit is contained in:
2026-10-21 14:32:21 +08:00
parent 6a88447524
commit d19fab55b9
7 changed files with 45 additions and 2 deletions
+1 -1
View File
@@ -200,7 +200,7 @@ Native measurement finds intrinsic subtree size and clamps the returned size to
A source subclass can override `paint(self, mount, geometry): DisplayList`. The renderer invokes that method for each occurrence, after Mount synchronization and hooks, using current logical Bounds. Its commands replace that occurrence's native paint in preorder. Calling `RectBlock.paint(self, mount, geometry)` or another native base method obtains a fresh result that can be modified before returning. `DisplayList(ObjectList(command, ...))` builds multiple commands; ObjectList accepts objects and has a 10000-member bound. PaintCommand fields use kind (`roundedRect`, `strokeRoundedRect` or `text`), x/y/color and the corresponding width/height/radius, strokeWidth, or text/size fields. Commands must pass the same native validation and a total 10000-command frame limit. See [source-paint.endor](examples/source-paint.endor), including a Button source method that updates the same tint field used by two occurrences.
Paint runs in a read-only Aster call: existing heap objects cannot be modified; fresh result graphs may be allocated and filled. Existing globals, model fields, containers, Mounts and types remain protected. invalidate is rejected in this phase. All overrides share one VM budget. Read dependencies are currently recorded per object, with versions used to detect changes without depending on bounded change-notification delivery. Native frames keep their existing dependency/cache behavior. Derived allocations do not produce application change notifications, preventing temporary results from causing redraw feedback. This protects managed heap writes; trusted Rust host implementations must also respect read-only calls for external state and I/O. Paint errors stop the affected runtime before publication; failed PUT candidates preserve the previously running heap and frame.
Renderer-dispatched paint runs in a read-only Aster call: existing heap objects cannot be modified; fresh result graphs may be allocated and filled. Existing globals, model fields, containers, Mounts and types remain protected. invalidate is rejected in this phase. All overrides share one VM budget. Read dependencies are currently recorded per object, with versions used to detect changes without depending on bounded change-notification delivery. Native frames keep their existing dependency/cache behavior. Derived allocations do not produce application change notifications, preventing temporary results from causing redraw feedback. This protects managed heap writes; trusted Rust host implementations must also respect read-only calls for external state and I/O. Paint errors stop the affected runtime before publication; failed PUT candidates preserve the previously running heap and frame.
Toggle developer tools with Command-Option-I or F12 on macOS, Control-Shift-I or
F12 on Windows/Linux. The compact Console, Sources, Network and Settings tabs
+6
View File
@@ -41,6 +41,9 @@ pub struct Block {
}
impl ObjectPayload for Block {
fn reference_assignment_only(&self) -> bool {
true
}
fn attribute_target(&self, store: &ObjectStore) -> Result<Option<ObjectRef>, VmError> {
let Value::Object(value) = store.cell_get(self.state)? else {
return Err(VmError::InvalidArgument("Block state is not an object"));
@@ -148,6 +151,9 @@ impl Data {
}
impl ObjectPayload for Data {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
+22
View File
@@ -801,6 +801,28 @@ mod tests {
const EXAMPLE: &str = include_str!("../examples/hello.endor");
const PAGE: &str = include_str!("../examples/page.endor");
#[test]
fn source_paint_can_rebind_old_plain_reference_to_new_result_without_mutating_it() {
let source = r##"class ReboundRect: RectBlock {
previous: ObjectList
function paint(self: ReboundRect, mount: Mount, geometry: Bounds): DisplayList {
drawing = self.previous
drawing = RectBlock.paint(self, mount, geometry)
return drawing
}
}
previous = ObjectList()
rect = ReboundRect(80, 40, 0, "#DDEEFF", previous)
page = Page()
page.render(rect)"##;
let (mut session, document) = ReplSession::load(source, "app.main", 75, 1).unwrap();
assert_eq!(document.frame.commands.len(), 1);
assert_eq!(
session.execute("previous.count", "app.main").unwrap().value,
"0"
);
}
#[test]
fn source_paint_overrides_native_commands_and_reacts_to_heap_field_writes() {
let (mut session, initial) = ReplSession::load(
+9
View File
@@ -20,6 +20,9 @@ pub struct Event {
prevented: bool,
}
impl ObjectPayload for Event {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
@@ -38,6 +41,9 @@ pub struct Connection {
pub capture: bool,
}
impl ObjectPayload for Connection {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
@@ -57,6 +63,9 @@ pub struct Subscription {
pub connection: WeakObjectRef,
}
impl ObjectPayload for Subscription {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
+3
View File
@@ -23,6 +23,9 @@ pub struct Mount {
}
impl ObjectPayload for Mount {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
+3
View File
@@ -6,6 +6,9 @@ use endor_core::{
#[derive(Debug)]
struct ObjectList(Vec<ObjectRef>);
impl ObjectPayload for ObjectList {
fn reference_assignment_only(&self) -> bool {
true
}
fn as_any(&self) -> &dyn std::any::Any {
self
}
+1 -1