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
This commit is contained in:
wooster0 2024-12-07 17:56:48 +09:00 committed by Matthew Lugg
parent e62aac3ec4
commit a221b2fbf2
2 changed files with 12 additions and 1 deletions

View File

@ -8999,7 +8999,7 @@ fn zirIntFromEnum(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
block,
operand_src,
"untagged union '{}' cannot be converted to integer",
.{src},
.{operand_ty.fmt(pt)},
);
};

View File

@ -0,0 +1,11 @@
const UntaggedUnion = union {};
comptime {
@intFromEnum(@as(UntaggedUnion, undefined));
}
// error
// backend=stage2
// target=native
//
// :3:18: error: untagged union 'tmp.UntaggedUnion' cannot be converted to integer
// :1:23: note: union declared here