authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2024-12-07 17:56:48+09:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-12-08 17:23:57+00:00
loga221b2fbf2829e2e8ba5ecd2d7569e619a66d69b
treef5290a3a9e0374966b5593174696975fd9fb6d3d
parente62aac3ec4b21da20d7c57d937e508f2929138d0

Sema: fix use of Zcu.LazySrcLoc in error message

It currently prints as: :3:18: error: untagged union 'Zcu.LazySrcLoc{ .base_node_inst = InternPool.TrackedInst.Index(104), .offset = Zcu.LazySrcLoc.Offset{ .node_offset = Zcu.LazySrcLoc.Offset.TracedOffset{ .x = -2, .trace = (value tracing disabled) } } }' cannot be converted to integer

2 files changed, 12 insertions(+), 1 deletions(-)

src/Sema.zig+1-1
......@@ -8999,7 +8999,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
89998999 block,
90009000 operand_src,
90019001 "untagged union '{}' cannot be converted to integer",
9002 .{src},
9002 .{operand_ty.fmt(pt)},
90039003 );
90049004 };
90059005
test/cases/compile_errors/untagged_union_integer_conversion.zig created+11
......@@ -0,0 +1,11 @@
1const UntaggedUnion = union {};
2comptime {
3 @intFromEnum(@as(UntaggedUnion, undefined));
4}
5
6// error
7// backend=stage2
8// target=native
9//
10// :3:18: error: untagged union 'tmp.UntaggedUnion' cannot be converted to integer
11// :1:23: note: union declared here