aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/invalid_multiple_dereferences.zig
blob: 53fc3d93c49030e973ed6001ab99de8013c44759 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
export fn a() void {
    var box = Box{ .field = 0 };
    _ = &box;
    box.*.field = 1;
}
export fn b() void {
    var box = Box{ .field = 0 };
    const box_ptr = &box;
    box_ptr.*.*.field = 1;
}
pub const Box = struct {
    field: i32,
};

// error
// backend=stage2
// target=native
//
// :4:8: error: cannot dereference non-pointer type 'tmp.Box'
// :11:17: note: struct declared here
// :9:14: error: cannot dereference non-pointer type 'tmp.Box'
// :11:17: note: struct declared here