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
[render] union type decl renders as <unknown type decl> (no Union branch) #1023
AUDIT finding (read-only review at 450733e, verified against source).
render.w has no Union branch: a union type decl falls through to <unknown type decl>.
src/render.w:78 handles only TypeDeclKind.Struct for brace-body types;
Alias (:93), Distinct (:100), Enum (:106), DiscEnum (:129) follow; Union
matches none and hits return out ++ "<unknown type decl>" (:152).
The Union layout IS the struct body layout: Parser.parse_struct_body
(src/Parser.w:1750) and parse_struct_body_block (:1818) both emit [count, 3N (name,type,default) triples, N aligns], and union
construction (Parser.w:1539-1555) uses the same body parser plus trailing is_pub/tp_start/tp_count — so the renderer could share the Struct
branch but does not.
Severity Low: no in-repo callers of any render_* entry point were found
(diagnostic/dump-only surface), so impact is confined to future dump use.
Closed in the same pass as non-findings: the alleged stride-3-vs-4 desync
is refuted (triples and aligns are separate arrays; type_decl_is_pub's +1+4N lands exactly on the trailing is_pub word both layouts emit);
zero-param fn name: parens and impl header-only rendering are held as
design judgments, not defects.
Verdict. The central claim is established by execution on the reported revision and on current main: a union type declaration renders as type Bits<unknown type decl>. Two corrections to the report's framing:
The renderer is reachable from the CLI, not dump-only-in-theory. with ast <file> and with check <file> --dump-ast both call render_module (src/main.w:3045, dispatched from :888-904), and spec §18.5 lists the ast subcommand and --dump-ast as diagnostic surface (implementation-internal, no stability guarantee). So the impact is a wrong diagnostic dump today, not a hypothetical future one.
opaque has the same gap.TypeDeclKind.Opaque (= 5) also has no branch and renders as type Handle<unknown type decl>.
The report's negative findings (no stride desync; type_decl_is_pub offset lands on the trailing is_pub word for both layouts) are consistent with what I read in the parser and are not contested.
Tested.
Source
main @ 5809ac1 (2026-09-14); src/render.w has no commits since 450733e
Compilers
with v0.15.2.1 built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed. Identical output
Platform
macOS Darwin 25.6.0 arm64
Input (u.w, spec §16 union spelling; with check u.w prints ok):
type Pair:
a: i32
b: i32
type Bits = union {
i: i32
f: f32
}
type Handle = opaque
fn main:
print("x")
with ast u.w (rc 0), both compilers:
type Pair { a: i32, b: i32 }
type Bits<unknown type decl>
type Handle<unknown type decl>
fn main:
print("x")
Expected: type Bits = union { i: i32, f: f32 } (or the renderer's house style for a brace body) and type Handle = opaque. Actual: the placeholder string for both. The struct control renders correctly. with check u.w --dump-ast prints the same two placeholder lines.
Root cause.src/render.w:78-152: the NK_TYPE_DECL renderer tests Struct, Alias, Distinct, Enum, DiscEnum in turn and returns out ++ "<unknown type decl>" for anything else; TypeDeclKind has seven values (src/Ast.w:202-209) and Union (6) and Opaque (5) are the two without a branch. The parser builds a union with the same extra layout as a struct body plus the trailing is_pub/tp_start/tp_count words (src/Parser.w:1543-1559), so the Struct branch can be shared with a union keyword; Opaque stores [0, is_pub, tp_start, tp_count] (:1536-1541). Established by source reading plus the run above; no debugger evidence is needed for a missing switch arm.
AGENTS.md angle. The placeholder is a silent fallback in a diagnostic tool: the dump reports success (rc 0) while emitting text that is not the program. Under "A tool that stayed silent is a bug", a renderer that cannot render a node should fail loudly (non-zero, naming the kind), not print a placeholder.
Related PRs. None touch src/render.w.
Recommendation. Fix, small. Acceptance criteria:
with ast on the file above round-trips Bits as a union with both fields and Handle as opaque; the output re-parses to the same AST.
ephemeral and pub prefixes and type parameters on a union render (the parser stores them at the same trailing offsets as for structs).
The fall-through becomes a loud failure (non-zero exit naming the TypeDeclKind value) rather than <unknown type decl>, so the next missing arm cannot hide.
A test/ fixture pins the rendered form for every TypeDeclKind value.
Not tested.@[repr(C)] and generic unions through the renderer (only the plain form above was executed).
Merged to main ae20d89 (#3248): a union type declaration renders through the struct-body branch as type U = union { … }; fixture test/internals/audit_small_fixes_test.w.
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced
Verdict. The central claim is established by execution on the reported revision and on current
main: a union type declaration renders astype Bits<unknown type decl>. Two corrections to the report's framing:with ast <file>andwith check <file> --dump-astboth callrender_module(src/main.w:3045, dispatched from:888-904), and spec §18.5 lists theastsubcommand and--dump-astas diagnostic surface (implementation-internal, no stability guarantee). So the impact is a wrong diagnostic dump today, not a hypothetical future one.opaquehas the same gap.TypeDeclKind.Opaque(= 5) also has no branch and renders astype Handle<unknown type decl>.The report's negative findings (no stride desync;
type_decl_is_puboffset lands on the trailingis_pubword for both layouts) are consistent with what I read in the parser and are not contested.Tested.
main@ 5809ac1 (2026-09-14);src/render.whas no commits since 450733ewith v0.15.2.1built from 5809ac1 (staging worktree); a compiler built from 450733e with the nightly-20260903 seed. Identical outputInput (
u.w, spec §16 union spelling;with check u.wprintsok):with ast u.w(rc 0), both compilers:Expected:
type Bits = union { i: i32, f: f32 }(or the renderer's house style for a brace body) andtype Handle = opaque. Actual: the placeholder string for both. The struct control renders correctly.with check u.w --dump-astprints the same two placeholder lines.Root cause.
src/render.w:78-152: theNK_TYPE_DECLrenderer testsStruct,Alias,Distinct,Enum,DiscEnumin turn and returnsout ++ "<unknown type decl>"for anything else;TypeDeclKindhas seven values (src/Ast.w:202-209) andUnion(6) andOpaque(5) are the two without a branch. The parser builds a union with the same extra layout as a struct body plus the trailingis_pub/tp_start/tp_countwords (src/Parser.w:1543-1559), so the Struct branch can be shared with aunionkeyword;Opaquestores[0, is_pub, tp_start, tp_count](:1536-1541). Established by source reading plus the run above; no debugger evidence is needed for a missing switch arm.AGENTS.md angle. The placeholder is a silent fallback in a diagnostic tool: the dump reports success (rc 0) while emitting text that is not the program. Under "A tool that stayed silent is a bug", a renderer that cannot render a node should fail loudly (non-zero, naming the kind), not print a placeholder.
Related PRs. None touch
src/render.w.Recommendation. Fix, small. Acceptance criteria:
with aston the file above round-tripsBitsas a union with both fields andHandleasopaque; the output re-parses to the same AST.ephemeralandpubprefixes and type parameters on a union render (the parser stores them at the same trailing offsets as for structs).TypeDeclKindvalue) rather than<unknown type decl>, so the next missing arm cannot hide.test/fixture pins the rendered form for everyTypeDeclKindvalue.Not tested.
@[repr(C)]and generic unions through the renderer (only the plain form above was executed).ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced;src/render.wstill has noUnion(orOpaque) branch and falls through at:159.post-release: it affects only the
with ast/--dump-astdiagnostic dump.Issues batch A: #1021 #1022 #1023 #2760 #3057 #3060 #3086 #3113 #3114 (…
ehartford commentedon Nov 11, 2026
Merged to main ae20d89 (#3248): a union type declaration renders through the struct-body branch as
type U = union { … }; fixture test/internals/audit_small_fixes_test.w.