You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constMyUnion=packedunion {
n: usize,
v: void,
fnnew() @This() {
returnMyUnion { .v= {} };
}
};
test"this should work at compiletime" {
comptime {
varmyUnion=MyUnion.new();
varf=myUnion.n;
}
}
However, when running zig test, it errors:
error: accessing union field 'n' while field 'v' is set
var f = myUnion.n;
The text was updated successfully, but these errors were encountered:
DutchGhost
changed the title
Packed/extern unions are checked within comptime blocks
Packed/extern unions are checked within comptime blocks, while they shouldn't
Aug 28, 2019
andrewrk
added
bug
Observed behavior contradicts documented or intended behavior
stage1
The process of building from source via WebAssembly and the C backend.
labels
Aug 28, 2019
git grep "extern union doesn't trigger field check at comptime" test
test/behavior/union.zig:test "extern union doesn't trigger field check at comptime" {
According to the documentation https://ziglang.org/documentation/master/#Wrong-Union-Field-Access, the following should work, because
extern
andpacked
unions dont have the wrong field access check:However, when running
zig test
, it errors:The text was updated successfully, but these errors were encountered: