From dbfeade22114d03c5f6dbf1f3f1d5946a10877a7 Mon Sep 17 00:00:00 2001 From: Justus Klausecker Date: Sat, 10 Jan 2026 18:17:58 +0100 Subject: [PATCH] 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! --- src/Sema.zig | 2 +- test/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 index fa066bcd33e2312555a3870f8559eaeb5a9d6d20..29c5c14702f6d3176a3b8de8e3cf694b4f59e887 100644 --- 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 index d505c6d2f122864d5973dcd8af0779d7a7331dcd..67eb2035ba59fb067a633e12aba38fef6fd5a2b7 100644 --- 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' -- 2.54.0