2026.05.14

  • YAML inputs with non-string dict keys (integers, dates, booleans) now flow through to the target language’s value-formatting path instead of being silently converted to string form. Languages that can represent the key natively (Python, Ruby, Clojure, Lua, Bash, and others) produce the corresponding literal; languages whose dict syntax requires string keys or a homogeneous typed map raise ~literalizer.exceptions.UnrepresentableInputError. The affected opt-out targets are the JSON family (already ~literalizer.Json5, ~literalizer.Jsonnet, ~literalizer.Toml), the string-keyed attribute-set languages (~literalizer.Nix, ~literalizer.Dhall, ~literalizer.Cobol), the statically-typed-map languages whose typed-map syntax has not yet been generalized (~literalizer.Go, ~literalizer.Kotlin, ~literalizer.CSharp, ~literalizer.Haskell, ~literalizer.Scala, ~literalizer.Dart, ~literalizer.VisualBasic, ~literalizer.FSharp, ~literalizer.Zig, ~literalizer.Odin, ~literalizer.Nim, ~literalizer.D, ~literalizer.TypeScript, ~literalizer.JavaScript), the languages that reject specific non-string key types at the language level (~literalizer.Php rejects DateTime keys, ~literalizer.V rejects bool keys), and the languages whose value ADTs do not currently model non-string keys (~literalizer.OCaml, ~literalizer.Sml, ~literalizer.R).

  • ~literalizer.literalize_call now accepts a variable_form argument (NewVariable or ExistingVariable) that wraps the rendered call in an idiomatic per-language variable binding (e.g. let my_data = make_widget(42);, const my_data = make_widget({ count: 42 });, my_data = make_widget(count=42)). Mutability and inference style are controlled by the per-language declaration_style and Modifiers enums on the supplied Language instance. BothVariableForms is rejected – emitting both a declaration and an assignment would invoke the target function twice – as is per_element=True (no per-element name vector) and any language whose call form is a statement rather than an expression (call_returns_expression=False). All three are surfaced as ~literalizer.exceptions.UnsupportedCallShapeError. The same exception is raised for languages whose declaration template wraps or transforms the right-hand side in a way that is only valid for literal values – Tcl (needs [...] command substitution), Bash (needs $(...) command substitution), Objective-C (@(...) boxing of primitives), tagged-enum heterogeneous-strategy languages (Roc, Haskell, Elm, SML, OCaml, PureScript, F#), C / SystemVerilog / Fortran / Ada / Zig / D (struct-initializer or constructor wrapping derived from the value’s literal type), Elixir (call stubs need module scope, not the variable’s function body), Erlang, Forth, and Nim. Closes #1961.

  • The internal ~literalizer._types.Value and ~literalizer._types.ValueInput aliases now permit any ~literalizer._types.Scalar as a dict key, in preparation for surface formats that admit non-string dict keys. A new ~literalizer.exceptions.UnrepresentableInputError and a supports_non_string_dict_keys class attribute on ~literalizer.Language (defaulting to True; overridden to False on ~literalizer.Json5, ~literalizer.Jsonnet, and ~literalizer.Toml) wire a centralized guard at the dict-formatting boundary. The surface parsers still produce only string-keyed dicts, so behavior is unchanged.

  • ~literalizer.literalize now accepts a ref_values mapping from ref identifier to the value declared elsewhere for that ref. Languages whose $ref rendering depends on the referenced type (V’s .clone() for arrays and maps, Mojo’s ^ for non-trivial values, C++’s std::move for non-trivially-copyable values) consult it to choose the right form; when omitted these languages keep their type-agnostic default. V now emits a bare identifier for scalar refs (int, bool, f64) because int.clone() is rejected by the V compiler; Mojo drops ^ for register-trivial scalars where it is a hard error under --Werror; Cpp drops std::move for trivially-copyable scalars where clang-tidy’s hicpp-move-const-arg rejects it. Preamble inference also walks the resolved ref_values so sum-type body declarations (Haskell’s data Val, OCaml’s val_t, Roc’s Val, …) include the variants needed by the referenced types. SystemVerilog’s literalize rejects scalar $ref markers via ~literalizer.exceptions.CallArgNotSupportedError: SV keys the variable declaration off the marker dict’s shape (_VKV name[]) and cannot produce a coherent declaration for a scalar referent.

  • The ~literalizer._language.Language.format_call_ref_identifier, ~literalizer._language.Language.format_call_arg_ref_identifier, and ~literalizer._language.Language.format_call_arg_ref_identifier_consumable hooks now receive a second positional argument: the Value behind the ref (or None when the caller did not supply ref_values). This is a breaking change for custom ~literalizer.Language implementations that override these hooks; most overrides ignore the new argument.

  • ~literalizer.V now defaults heterogeneous_strategy to V.heterogeneous_strategies.ERROR and reports dict_supports_heterogeneous_values=False and supports_heterogeneity=False on its sequence and set formats. V is statically typed and rejects unwrapped heterogeneous collections, so rendering them now raises rather than emitting code the V compiler will not accept. Callers that want to materialize heterogeneous data must opt in to V.heterogeneous_strategies.INTERFACE, which wraps values with IVal(...) and emits the interface IVal {} declaration as before.