aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_wrong_union_access.zig
blob: 0c89c3d4fafb62c7ee2fbb4171a23eec703f1a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
const Payload = union {
    int: i64,
    float: f64,
    boolean: bool,
};
test "simple union" {
    var payload = Payload{ .int = 1234 };
    payload.float = 12.34;
}

// test_error=access of union field 'float' while field 'int' is active