Odin icon indicating copy to clipboard operation
Odin copied to clipboard

Getting error "A union with #no_nil must have at least 2 variants" for a polymorphic union, even when it has 2 variants

Open 2DArray opened this issue 2 years ago • 0 comments

Context

    Odin: dev-2023-03:fe533fb8
    OS:   Windows 10 Home Basic (version: 21H2), build 19044.2728
    CPU:  Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    RAM:  16246 MiB

Expected Behavior

This "#no_nil union must have 2+ variants" is only fired in the situation that it describes

Current Behavior

The following union causes the error, even though it does have two variants:

BadUnion :: union($T: typeid) #no_nil {
    int,
    f32,
}

As shown above, the error is thrown whenever the union has the (T) parameter - even if the T type isn't actually used in any of the variants.

Failure Information (for bugs)

Steps to Reproduce

Compile an otherwise-empty project (just a no-op main() procedure) which defines the above BadUnion(T) type

2DArray avatar Mar 20 '23 01:03 2DArray