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!
This commit is contained in:
Justus Klausecker 2026-01-10 18:17:58 +01:00 committed by Matthew Lugg
parent 2e99c3042e
commit dbfeade221
No known key found for this signature in database
GPG key ID: 3F5B7DCCBF4AF02E
2 changed files with 2 additions and 3 deletions

View file

@ -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),
});
}

View file

@ -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'