Before this fix, passing an undefined union value to `Sema.switchCond` returned an undefined value of the union type, not the tag type, since `Value.unionTag` forwards undefined values unchanged. This leads us into the `.Union` branch in `Sema.zirSwitchBlock` which is unreachable, now we take the `.Enum` branch instead.
13 lines
254 B
Zig
13 lines
254 B
Zig
export fn entry() void {
|
|
const U = union(enum) { a: bool, b: bool };
|
|
switch (@as(U, undefined)) {
|
|
.a, .b => {},
|
|
}
|
|
}
|
|
|
|
// error
|
|
// backend=stage2
|
|
// target=native
|
|
//
|
|
// :3:5: error: use of undefined value here causes undefined behavior
|