Commit ab3ac1e670
src/value.zig
@@ -398,7 +398,11 @@ pub const Value = struct {
},
.un => |un| Tag.@"union".create(arena, .{
- .tag = un.tag.toValue(),
+ // toValue asserts that the value cannot be .none which is valid on unions.
+ .tag = .{
+ .ip_index = un.tag,
+ .legacy = undefined,
+ },
.val = un.val.toValue(),
}),
test/behavior/union.zig
@@ -1662,3 +1662,16 @@ test "union with 128 bit integer" {
}
}
}
+
+test "memset extern union at comptime" {
+ const U = extern union {
+ foo: u8,
+ };
+ const u = comptime blk: {
+ var u: U = undefined;
+ @memset(std.mem.asBytes(&u), 0);
+ u.foo = 0;
+ break :blk u;
+ };
+ try expect(u.foo == 0);
+}