Zig Version
0.16.0-dev.3146+0606af509
Steps to Reproduce and Observed Behavior
// var v: V = .{ .int = 2 };// v = .{ .float = @floatFromInt(v.int) };//// Codegen writes tag = .float into v before evaluating the RHS.// v.int then panics with "access of union field 'int' while field// 'float' is active". With switch(v) the safety check is bypassed// and the i64 payload is silently reinterpreted as f64.//// Expected: v.float == 2.0// Actual: assertion failure (v.float ≈ 1e-323, raw bits = 0x2)//// Workaround: const tmp = v; v = .{ .float = ... tmp ... };conststd=@import("std");constV=union(enum){int:i64,float:f64};pubfnmain()void{varv:V=.{.int=2};v=.{.float=switch(v){.int=>|n|@as(f64,@floatFromInt(n)),.float=>|f|f,}};std.debug.assert(v==.float);std.debug.assert(v.float==2.0);}Expected Behavior
Pass without exceptions
### Zig Version
0.16.0-dev.3146+0606af509
### Steps to Reproduce and Observed Behavior
```zig
// var v: V = .{ .int = 2 };
// v = .{ .float = @floatFromInt(v.int) };
//
// Codegen writes tag = .float into v before evaluating the RHS.
// v.int then panics with "access of union field 'int' while field
// 'float' is active". With switch(v) the safety check is bypassed
// and the i64 payload is silently reinterpreted as f64.
//
// Expected: v.float == 2.0
// Actual: assertion failure (v.float ≈ 1e-323, raw bits = 0x2)
//
// Workaround: const tmp = v; v = .{ .float = ... tmp ... };
const std = @import("std");
const V = union(enum) { int: i64, float: f64 };
pub fn main() void {
var v: V = .{ .int = 2 };
v = .{ .float = switch (v) {
.int => |n| @as(f64, @floatFromInt(n)),
.float => |f| f,
} };
std.debug.assert(v == .float);
std.debug.assert(v.float == 2.0);
}
```
### Expected Behavior
Pass without exceptions