You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Keep type structure in the compiled schema (fixed array length, f32/f64, unions) #95
Freezing turns a field's type into text (KindValue::Namespaced("T[]", _)), and the text drops information:
Fixed array length.T[8] and T[] both freeze to "T[]". Generators can't emit [T; 8], nothing checks the length, and validator.rs's detect_cycle (ends_with("[]")) treats every array as a cycle escape, so struct Node { next: Node[4] } isn't caught. schema/idl/size.rs works on the AST instead of the IR because of this.
f32 vs f64. Both freeze to "float", so comline-rust's map_str_type emits f64 for an f32 field.
Unions. comline-rust's rust_type has no case for KindValue::Union and emits /* unknown_kind */.
Proposal
Freeze types as a structured value instead of a string: element type, array shape (dynamic, or fixed N), exact primitive. Generators render from that instead of parsing strings with strip_suffix("[]").
This shares a prerequisite with running validators (#96, step 4a: the validate condition also needs freezing as a tree). Doing both in one IR revision means one format bump, not two. .comline/ is CBOR with name-tagged fields, so old stores can still be read with #[serde(default)] where a field is added.
It is also the prerequisite for bounds written on types (#98).
Tasks
Structured type in FrozenUnit::Field, FrozenArgument, TypeAlias::target, constants
Keep fixed array length; keep f32/f64 distinct
detect_cycle: only a dynamic array breaks a cycle
Generators (generation/codegen kernel, comline-rust, comline-typescript) render from the structured type: [T; N] / fixed tuples or arrays as each target decides, f32 → f32, unions
Activity