zig
zig copied to clipboard
@unionInit should get its type from its result location
Zig Version
0.12.0-dev.3381+7057bffc1
Steps to Reproduce and Observed Behavior
@unionInit(comptime Union: type, comptime active_field_name: []const u8, init_expr) Union
Expected Behavior
@unionInit(comptime active_field_name: []const u8, init_expr) Union
const U = union(enum) {
a: u32,
b: u16,
c: u64,
};
test {
const x: U = @unionInit("a", 0);
_ = x;
}
natural continuation of https://github.com/ziglang/zig/issues/5909
also meshes well with WIP changes to make @fieldParentPtr do the same