diff --git a/crates/tx3-lang/src/ast.rs b/crates/tx3-lang/src/ast.rs index 37dd4d1..ec3856d 100644 --- a/crates/tx3-lang/src/ast.rs +++ b/crates/tx3-lang/src/ast.rs @@ -637,7 +637,11 @@ impl MapConstructor { let value_type = first_field.value.target_type()?; Some(Type::Map(Box::new(key_type), Box::new(value_type))) } else { - None + // Empty map literal: element types are unknown from the literal + // alone. Return a Map with Undefined inner types so the analyzer + // can still treat this as a Map; type coherence is checked by the + // enclosing context (e.g. a struct field of declared Map type). + Some(Type::Map(Box::new(Type::Undefined), Box::new(Type::Undefined))) } } } diff --git a/crates/tx3-lang/src/tx3.pest b/crates/tx3-lang/src/tx3.pest index 831072a..ea27be1 100644 --- a/crates/tx3-lang/src/tx3.pest +++ b/crates/tx3-lang/src/tx3.pest @@ -199,7 +199,7 @@ map_field = { } map_constructor = { - "{" ~ (map_field ~ ",")+ ~ "}" + "{" ~ (map_field ~ ",")* ~ "}" } // input block