aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/union_access_of_inactive_field.zig
blob: ccbdc5b2a03a839ba80e102d695e5dca0ef1e844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const U = union {
    a: void,
    b: u64,
};
comptime {
    var u: U = .{ .a = {} };
    const v = u.b;
    _ = &u;
    _ = v;
}

// error
//
// :7:16: error: access of union field 'b' while field 'a' is active
// :1:11: note: union declared here