Open
Description
Continued from #12462 (comment)
This feature is of questionable usefulness since it is only valid for unions with all zero bit type fields which are quite rare. It is not used anywhere in the std, the self hosted compiler or even in the behavior tests and probably not in any third party project. It could be made more useful by turning the compile error into runtime safety checks but that could be seen as too implicit with the preferred way to handle it being a switch:
test {
const E = enum { a, b };
const U = union(E) {
a: void,
b: u32,
};
var u: U = undefined;
var e: E = .a;
u = switch (e) {
.a => .a,
.b => unreachable,
};
}