zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit dbfeade22114d03c5f6dbf1f3f1d5946a10877a7 (tree)
parent 2e99c3042e2641dda21768a898905784aa939031
Author: Justus Klausecker <justus@klausecker.de>
Date:   Sat, 10 Jan 2026 18:17:58 +0100

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!

Diffstat:
Msrc/Sema.zig | 2+-
Mtest/cases/compile_errors/switch_on_non_err_union.zig | 3+--
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/Sema.zig b/src/Sema.zig @@ -10590,7 +10590,7 @@ fn zirSwitchBlockErrUnion(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Comp break :err_union_ty raw_operand_ty.childType(zcu); }; if (err_union_ty.zigTypeTag(zcu) != .error_union) { - return sema.fail(block, src, "expected error union type, found '{f}'", .{ + return sema.fail(block, operand_src, "expected error union type, found '{f}'", .{ err_union_ty.fmt(pt), }); } diff --git a/test/cases/compile_errors/switch_on_non_err_union.zig b/test/cases/compile_errors/switch_on_non_err_union.zig @@ -5,6 +5,5 @@ pub fn main() void { } // error -// target=x86_64-linux // -// :2:23: error: expected error union type, found 'bool' +// :2:11: error: expected error union type, found 'bool'