behavior: add test for old bug

Resolves: #2289
This commit is contained in:
mlugg 2025-02-05 23:07:43 +00:00
parent b21becb2a6
commit 6bd92a21b7
No known key found for this signature in database
GPG Key ID: 3F5B7DCCBF4AF02E

View File

@ -2322,3 +2322,19 @@ test "assign global tagged union" {
try expect(U.global == .b);
try expect(U.global.b == 123456);
}
test "set mutable union by switching on same union" {
const U = union(enum) {
foo,
bar: usize,
};
var val: U = .foo;
val = switch (val) {
.foo => .{ .bar = 2 },
.bar => .foo,
};
try expect(val == .bar);
try expect(val.bar == 2);
}