1// This tests that the variant of an error union is runtime-known when the value is runtime-known.
2// This might seem obvious but previously the compiler special-cased the situation where a const
3// was assigned a payload or error value, i.e. instead of another error union.
4
5export fn foo() void {
6 var runtime_payload: u8 = 0;
7 _ = &runtime_payload;
8 const eu: error{a}!u8 = runtime_payload;
9 if (eu) |_| {} else |_| @compileError("analyzed");
10}
11
12export fn bar() void {
13 var runtime_error: error{a} = error.a;
14 _ = &runtime_error;
15 const eu: error{a}!u8 = runtime_error;
16 if (eu) |_| @compileError("analyzed") else |_| {}
17}
18
19// error
20//
21// :9:29: error: analyzed
22// :16:17: error: analyzed