Invalidate rendering when typed method storage is shadowed

This commit is contained in:
2026-10-22 15:28:47 +08:00
parent ab40e424e0
commit b2fe392ddb
5 changed files with 71 additions and 2 deletions
+1 -1
View File
@@ -10,7 +10,7 @@
| ui_bridge.rs | Inheritable native nominal constructors with source fields, shared type method tables and bound receiver dispatch, configured unified Function classification and source/field/override checks with deferred typed public/native constructor signatures and split option/field preflight plus shared native arity intervals plus resolved types/unions/effects on methods, tab registry, stable-slot insertion, source-dispatched tab reorder/drop and callback registration checks, Page lifecycle/navigation and immutable frame extraction |
| binding.rs | Target-owned managed property bindings, weak Subscription tokens, zero-argument callback preflight, read-only compute and borrowed dependency/output caches |
| block.rs | Aster-managed Block/Cell/data graph, stable child slots, content-owned field storage, shared assignment, cycle validation and explicit text bindings |
| snapshot.rs | Property and visual-method identity dependencies across shared field-storage paths, reverse parent links and cached immutable visual derivation |
| snapshot.rs | Property and visual-method identity dependencies across shared field-storage paths, typed method attribute validity dependencies, reverse parent links and cached immutable visual derivation |
| mount.rs | Typed per-occurrence methods and nominal Bounds results, managed contexts, weak reverse links, ordered mount/unmount hooks, geometry and focus queries |
| events.rs | Bounded native input transport with kind-specific tab-drop/desktop-position metadata to the owning VM |
| event_dispatch.rs | Typed Event factory and managed Event/Subscription methods, weak Subscription tokens, Block-owned connections and occurrence-specific capture/target/bubble through a budgeted VM driver |
+56
View File
@@ -3938,6 +3938,62 @@ page.render(block)
);
}
#[test]
fn typed_method_shadows_invalidate_cached_ancestors_and_can_be_removed() {
let mut session = ReplSession::new(233).unwrap();
session
.execute(
"rect = RectBlock(40, 20) root = ColumnBlock(0, 0, rect)",
"app.main",
)
.unwrap();
let globals = session.candidate.globals.unwrap();
let lookup = |name: &str| match session
.candidate
.vm
.dict_get(globals, &Value::Text(name.into()))
.unwrap()
.unwrap()
{
Value::Object(value) => value,
_ => panic!("object"),
};
let rect = lookup("rect");
let root = lookup("root");
for name in ["paint", "measure", "onEvent"] {
let error = session
.execute(&format!("rect.{name} = 1"), "app.main")
.err()
.expect("typed method cannot be shadowed");
assert!(
error.to_string().contains("instance attribute shadows"),
"{error:#}"
);
}
let vm = &mut session.candidate.vm;
let storage = *vm
.object_store()
.attribute_path(rect)
.unwrap()
.last()
.unwrap();
let mut cache = crate::snapshot::RenderCache::default();
cache.snapshot(vm.object_store(), root).unwrap();
vm.take_changes();
cache.snapshot(vm.object_store(), root).unwrap();
assert_eq!(cache.visited, 0);
vm.set_attr(storage, "paint", Value::Nil).unwrap();
cache.invalidate(vm.take_changes());
assert!(matches!(
cache.snapshot(vm.object_store(), root),
Err(endor_core::VmError::TraitViolation { .. })
));
vm.del_attr(storage, "paint").unwrap();
cache.invalidate(vm.take_changes());
cache.snapshot(vm.object_store(), root).unwrap();
assert!(cache.visited > 0);
}
#[test]
fn presentable_type_contracts_reject_before_registration_or_body_effects() {
let mut session = ReplSession::new(232).unwrap();
+11
View File
@@ -123,6 +123,7 @@ impl RenderCache {
return Err(VmError::ExecutionLimit("expanded Block graph"));
}
}
store.check_typed_instance_storage(block)?;
let (data_ref, raw_data, raw_dependencies) = block::resolve_tracked(store, block)?;
let data = block::visual_data(store, raw_data)?;
let mut dependencies: Vec<_> = raw_dependencies
@@ -132,6 +133,16 @@ impl RenderCache {
property: None,
})
.collect();
let storage = *store
.attribute_path(block)?
.last()
.expect("nonempty attribute path");
for name in store.typed_method_names(block)? {
dependencies.push(Dependency {
object: storage,
property: Some(name),
});
}
if let Some(properties) = data.properties {
for (name, _) in block::native_properties(&data) {
dependencies.push(Dependency {