Give Result a single uniform/canonical LLVM layout so a value of any payload type can pass through a generic (r :: Result) parameter or return.
Problem
A generic (r :: Result) param currently lowers to {i8, double} (discriminant + f64 payload slot), but a composite-payload Result is {i8, {ptr, i64}} (e.g. Ok(Text), Ok([]Text)). LLVM rejects the call because the aggregate types don't match. Result deliberately has no canonical sum_layouts entry today — its shape follows the concrete payload — so any function taking a bare Result can only accept discriminant-compatible (f64-payload) values.
This blocks core.test's assertOk/assertNotOk (and any user helper) from operating on a Result carrying a composite payload. Surfaced by core.cli (getEnv → Ok(Text), getOpt → Ok([]Text)): the self-asserting example must verify presence via match → Bool + assert(...) instead of assertOk/assertNotOk.
Decision (LOCKED)
Full uniform/canonical Result representation — a single layout that construction, every ?/| match, and all Result params/returns agree on, so any payload passes through a generic Result. Chosen over a narrow discriminant-only call-site coercion (a band-aid that wouldn't let the payload be used through a generic Result).
Scope
Part of M4 (monomorphization + authoritative types in codegen). Cross-cutting: touches Result construction, matching/extraction, and Result-typed params/returns. Not a blocker for core.cli (#66) — that ships with the match → Bool + assert workaround.
Unblocks
assertOk/assertNotOk on composite-payload Results everywhere (convert the core.cli example off the match → Bool workaround).
- General use of composite-payload
Result values through generic Result params/returns.
Give
Resulta single uniform/canonical LLVM layout so a value of any payload type can pass through a generic(r :: Result)parameter or return.Problem
A generic
(r :: Result)param currently lowers to{i8, double}(discriminant + f64 payload slot), but a composite-payloadResultis{i8, {ptr, i64}}(e.g.Ok(Text),Ok([]Text)). LLVM rejects the call because the aggregate types don't match.Resultdeliberately has no canonicalsum_layoutsentry today — its shape follows the concrete payload — so any function taking a bareResultcan only accept discriminant-compatible (f64-payload) values.This blocks
core.test'sassertOk/assertNotOk(and any user helper) from operating on aResultcarrying a composite payload. Surfaced bycore.cli(getEnv → Ok(Text),getOpt → Ok([]Text)): the self-asserting example must verify presence viamatch → Bool+assert(...)instead ofassertOk/assertNotOk.Decision (LOCKED)
Full uniform/canonical
Resultrepresentation — a single layout that construction, every?/|match, and allResultparams/returns agree on, so any payload passes through a genericResult. Chosen over a narrow discriminant-only call-site coercion (a band-aid that wouldn't let the payload be used through a genericResult).Scope
Part of M4 (monomorphization + authoritative types in codegen). Cross-cutting: touches Result construction, matching/extraction, and Result-typed params/returns. Not a blocker for core.cli (#66) — that ships with the
match → Bool+assertworkaround.Unblocks
assertOk/assertNotOkon composite-payload Results everywhere (convert thecore.cliexample off thematch → Boolworkaround).Resultvalues through genericResultparams/returns.