Skip to content

Generic instantiated at Unit (forall<T> over @Unit) is check-green but fails/crashes at codegen #900

Description

@aallan

Found during the PR #899 (#878) review; pre-existing on both the release/v0.1.0 branch and main (not introduced by #878).

Symptom

A generic instantiated at the zero-size Unit type passes vera check but fails at codegen:

private fn mku(@Int -> @Unit) requires(true) ensures(true) effects(pure) { () }
private forall<T> fn idt(@T -> @T) requires(true) ensures(true) effects(pure) { @T.0 }
public fn main(@Unit -> @Int) requires(true) ensures(true) effects(pure)
{ let @Unit = idt(mku(5)); 7 }
  • vera check → OK.
  • vera runfails, and the exact failure is hash-seed-dependent: observed E699 (function skipped), "No exported functions to call" (main dropped), and — worst — a codegen invariant violation — … the type checker should have rejected the input before it reached this point. Please file a bug report crash.

The crash message is itself telling: the codegen invariant expects the checker to have already rejected forall<T> at T = Unit.

Nature

Instantiating a generic at Unit is a degenerate/niche case (identity over a zero-size value). The right fix is likely a checker-side clean rejection (a proper diagnostic that generics may not be instantiated at Unit, if that's the intended design) rather than a codegen change — OR codegen support for the Unit monomorphization. Either way, a check-green program must not reach a "file a bug report" codegen crash.

Pre-existing; surfaced by an edge-shape probe during #878's clone-naming work. Related: #878 (the user-fn-return-into-generic-arg clone naming this sits adjacent to).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions