diff --git a/src/Sema.zig b/src/Sema.zig index 0f8668c4ad..33e2436b90 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -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)}, ); }; diff --git a/test/cases/compile_errors/untagged_union_integer_conversion.zig b/test/cases/compile_errors/untagged_union_integer_conversion.zig new file mode 100644 index 0000000000..ab60793ff2 --- /dev/null +++ b/test/cases/compile_errors/untagged_union_integer_conversion.zig @@ -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