authorgravatar for justus@klausecker.deJustus Klausecker <justus@klausecker.de> 2026-01-10 18:17:58+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-11 11:37:18+00:00
logdbfeade22114d03c5f6dbf1f3f1d5946a10877a7
tree530814d90c591b42c1f06f505b969180ebd24459
parent2e99c3042e2641dda21768a898905784aa939031
signaturelock-open Commit is signed but in an unrecognized format.

Sema: better `switch_block_err_union` result location if operand has wrong type

also fixes related test case and makes it run everywhere, not just on x86_64-linux!

2 files changed, 2 insertions(+), 3 deletions(-)

src/Sema.zig+1-1
......@@ -10590,7 +10590,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp
1059010590 break :err_union_ty raw_operand_ty.childType(zcu);
1059110591 };
1059210592 if (err_union_ty.zigTypeTag(zcu) != .error_union) {
10593 return sema.fail(block, src, "expected error union type, found '{f}'", .{
10593 return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{
1059410594 err_union_ty.fmt(pt),
1059510595 });
1059610596 }
test/cases/compile_errors/switch_on_non_err_union.zig+1-2
......@@ -5,6 +5,5 @@ pub fn main() void {
55}
66
77// error
8// target=x86_64-linux
98//
10// :2:23: error: expected error union type, found 'bool'
9// :2:11: error: expected error union type, found 'bool'