authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-02-08 14:21:08+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-03-10 10:26:10+00:00
logda2006a38c63ac84aa9a075193bd72cf2d1716a2
tree794337cb06b934daddf1ee1d59a663d35d0b6125
parent4f7344dec0bc61916f0c9af99bc5b5e5b7167da3
signature Commit is signed but in an unrecognized format.

tests: unions without fields need not store their tag at runtime

...because the union semantically has no possible value so cannot be stored to or loaded from memory anyway.

1 files changed, 1 insertions(+), 5 deletions(-)

test/behavior/union.zig+1-5
......@@ -1020,7 +1020,7 @@ test "containers with single-field enums" {
10201020 try comptime S.doTheTest();
10211021}
10221022
1023test "@unionInit on union with tag but no fields" {
1023test "@unionInit on union with u8 tag but no fields" {
10241024 if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
10251025 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
10261026
......@@ -1036,10 +1036,6 @@ test "@unionInit on union with tag but no fields" {
10361036 }
10371037 };
10381038
1039 comptime {
1040 assert(@sizeOf(Data) == 1);
1041 }
1042
10431039 fn doTheTest() !void {
10441040 var data: Data = .{ .no_op = {} };
10451041 _ = &data;