-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.
Milestone
Description
According to the documentation https://ziglang.org/documentation/master/#Wrong-Union-Field-Access, the following should work, because extern
and packed
unions dont have the wrong field access check:
const MyUnion = packed union {
n: usize,
v: void,
fn new() @This() {
return MyUnion { .v = {} };
}
};
test "this should work at compiletime" {
comptime {
var myUnion = MyUnion.new();
var f = myUnion.n;
}
}
However, when running zig test
, it errors:
error: accessing union field 'n' while field 'v' is set
var f = myUnion.n;
JinShil
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstage1The process of building from source via WebAssembly and the C backend.The process of building from source via WebAssembly and the C backend.