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
Inferless enum-variant shorthand in a discard binding crashes codegen instead of a sema diagnostic #694
Found by tools/drop_audit.w (discard/option cell). Minimal repro:
fn main:
let _ = .Some(5)
print("ok")
with build → error: aggregate rvalue missing destination struct type fn=main count=1 dest_sema=42 current_ret=void / code generation failed.
The .Variant shorthand has no expected type here, so sema should reject it with a clean "cannot infer enum type for .Some" diagnostic; instead it passes sema and codegen dies on the missing destination. Error-quality/robustness, not soundness. (Annotated forms let _: Option[i32] = .Some(5) and ordinary bindings work fine.)
Fixed (two commits): the variant_lookup fallback returned a GENERIC enum's template tid as an expression type — codegen has no layout for it, so let _ = .Some(5) crashed on aggregate lowering and let x = .Some(5) + match died on invalid MIR (worse than filed — the ordinary-binding form had regressed to a crash too). An unknown payload-carrying variant (.Missing(5)) crashed as well.
Now: a generic template resolved without an expected type errors 'cannot infer the enum type for .Some' with an annotate-the-binding help; an unknown PAYLOAD-CARRYING variant errors 'no enum in scope has a variant'. Bare shorthands keep the silent deferred-completion path (the comprehension _Empty marker and bare None ahead of their expected type are completed by a later pass — the first suite run caught exactly that on spec_ss13_6a). Annotated forms and non-generic user-enum shorthands unchanged. Full :test green.
Possible ergonomics follow-up (not smuggled into the crash fix): payload-driven instantiation — .Some(5) could infer Option[i32] from the argument and remove the annotation entirely.
Activity
Docs: handoff — #682-inc1 landed (33b8517); auditor discoveries #693/#…
Tools: drop-audit matrix as a repo-committed With tool + :drop-audit …
ehartford commentedon Sep 1, 2026
Fixed (two commits): the variant_lookup fallback returned a GENERIC enum's template tid as an expression type — codegen has no layout for it, so
let _ = .Some(5)crashed on aggregate lowering andlet x = .Some(5)+ match died on invalid MIR (worse than filed — the ordinary-binding form had regressed to a crash too). An unknown payload-carrying variant (.Missing(5)) crashed as well.Now: a generic template resolved without an expected type errors 'cannot infer the enum type for .Some' with an annotate-the-binding help; an unknown PAYLOAD-CARRYING variant errors 'no enum in scope has a variant'. Bare shorthands keep the silent deferred-completion path (the comprehension _Empty marker and bare None ahead of their expected type are completed by a later pass — the first suite run caught exactly that on spec_ss13_6a). Annotated forms and non-generic user-enum shorthands unchanged. Full :test green.
Possible ergonomics follow-up (not smuggled into the crash fix): payload-driven instantiation —
.Some(5)could infer Option[i32] from the argument and remove the annotation entirely.sema: inferless generic-enum variant shorthand is a clean diagnostic (#…
sema: bare unknown variant shorthand stays deferred; only payload-car…