authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-05 23:07:43+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-02-06 00:51:59+00:00
log6bd92a21b7f31de913c7383ea380f3b68d387395
tree96ae1833b79ab147fca662f529335b99ec2742db
parentb21becb2a6a82b4ac65e98fa0094a7786cbbfdc3
signaturelock-open Commit is signed but in an unrecognized format.

behavior: add test for old bug

Resolves: #2289

1 files changed, 16 insertions(+), 0 deletions(-)

test/behavior/union.zig+16
......@@ -2322,3 +2322,19 @@ test "assign global tagged union" {
23222322 try expect(U.global == .b);
23232323 try expect(U.global.b == 123456);
23242324}
2325
2326test "set mutable union by switching on same union" {
2327 const U = union(enum) {
2328 foo,
2329 bar: usize,
2330 };
2331
2332 var val: U = .foo;
2333 val = switch (val) {
2334 .foo => .{ .bar = 2 },
2335 .bar => .foo,
2336 };
2337
2338 try expect(val == .bar);
2339 try expect(val.bar == 2);
2340}