zig/doc/langref/test_comptime_wrong_union_field_access.zig

12 lines
191 B
Zig

comptime {
var f = Foo{ .int = 42 };
f.float = 12.34;
}
const Foo = union {
float: f32,
int: u32,
};
// test_error=access of union field 'float' while field 'int' is active