Sema: fix initializing comptime-known constant with OPV union field

Resolves: #24716
This commit is contained in:
mlugg
2025-08-06 15:00:58 +01:00
committed by Matthew Lugg
parent 44ea11d71f
commit 3de8bbd3d4
2 changed files with 13 additions and 5 deletions

View File

@@ -2311,3 +2311,11 @@ test "set mutable union by switching on same union" {
try expect(val == .bar);
try expect(val.bar == 2);
}
test "initialize empty field of union inside comptime-known struct constant" {
const Inner = union { none: void, some: u8 };
const Wrapper = struct { inner: Inner };
const val: Wrapper = .{ .inner = .{ .none = {} } };
comptime assert(val.inner.none == {});
}