From a4b48ce2370d67bfe6b882501b5077990cc4329e Mon Sep 17 00:00:00 2001 From: Tim Fennis Date: Wed, 2 Sep 2026 15:52:21 +0200 Subject: [PATCH] =?UTF-8?q?docs(vm):=20correct=20the=20element=20types=20O?= =?UTF-8?q?bject::static=5Ftype=20reports=20=F0=9F=93=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The comment said container element types are reported as `Any` with `Tuple` as the sole exception. Lists, deques, maps, and `Some` read their element types from their contents too — as the `Performance` note on `Value::static_type` directly above already says. Iterators and heaps are the ones that report `Any`. Co-Authored-By: Claude Opus 5 (1M context) --- ndc_vm/src/value/mod.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ndc_vm/src/value/mod.rs b/ndc_vm/src/value/mod.rs index 78c48460..bb44dd62 100644 --- a/ndc_vm/src/value/mod.rs +++ b/ndc_vm/src/value/mod.rs @@ -672,9 +672,14 @@ impl Object { /// Returns the best static type descriptor for this runtime value. /// - /// Container element types (List, Map, Iterator, …) are reported as `Any` - /// because the VM does not track element types at runtime. Tuple is the - /// exception: its element types are known from the concrete values it holds. + /// `[1, 2]` reports `List` and `%{"a": 1}` reports `Map`: + /// lists and deques join their element types into a least upper bound, while + /// maps do so separately for keys and values. Tuples preserve each position's + /// type, and `Some` wraps the type of its inner value. Empty lists, deques, and + /// maps report `Any` for the types they cannot infer. + /// + /// Iterators and heaps always report `Any` elements, because inspecting them + /// would consume or expose their internal values. pub fn static_type(&self) -> StaticType { let mut budget = usize::MAX; self.static_type_with_budget(usize::MAX, &mut budget)