mirror of
https://github.com/ziglang/zig.git
synced 2026-01-10 09:25:11 +00:00
parent
1606717b5f
commit
ab3ac1e670
@ -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(),
|
||||
}),
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user