1const EnumInferred = enum {};
2const EnumExplicit = enum(noreturn) {};
3const EnumNonexhaustive = enum(u8) { _ };
4
5const U0 = union {};
6const U1 = union(enum) {};
7const U2 = union(enum(noreturn)) {};
8const U3 = union(EnumInferred) {};
9const U4 = union(EnumExplicit) {};
10const U5 = union(EnumNonexhaustive) {};
11
12export fn init0() void {
13 _ = @as(U0, undefined);
14}
15export fn init1() void {
16 _ = @as(U1, undefined);
17}
18export fn init2() void {
19 _ = @as(U2, undefined);
20}
21export fn init3() void {
22 _ = @as(U3, undefined);
23}
24export fn init4() void {
25 _ = @as(U4, undefined);
26}
27export fn init5() void {
28 _ = @as(U5, undefined);
29}
30
31// error
32//
33// :13:17: error: expected type 'tmp.U0', found '@TypeOf(undefined)'
34// :13:17: note: cannot coerce to uninstantiable type 'tmp.U0'
35// :5:12: note: union declared here
36// :16:17: error: expected type 'tmp.U1', found '@TypeOf(undefined)'
37// :16:17: note: cannot coerce to uninstantiable type 'tmp.U1'
38// :6:12: note: union declared here
39// :19:17: error: expected type 'tmp.U2', found '@TypeOf(undefined)'
40// :19:17: note: cannot coerce to uninstantiable type 'tmp.U2'
41// :7:12: note: union declared here
42// :22:17: error: expected type 'tmp.U3', found '@TypeOf(undefined)'
43// :22:17: note: cannot coerce to uninstantiable type 'tmp.U3'
44// :8:12: note: union declared here
45// :25:17: error: expected type 'tmp.U4', found '@TypeOf(undefined)'
46// :25:17: note: cannot coerce to uninstantiable type 'tmp.U4'
47// :9:12: note: union declared here
48// :28:17: error: expected type 'tmp.U5', found '@TypeOf(undefined)'
49// :28:17: note: cannot coerce to uninstantiable type 'tmp.U5'
50// :10:12: note: union declared here