aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/fieldParentPtr-comptime_wrong_field_index.zig
blob: a73409aea3368300a6a397f0dffc2db57f913c7a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const Foo = struct {
    a: i32,
    b: i32,
};
const foo = Foo { .a = 1, .b = 2, };

comptime {
    const another_foo_ptr = @fieldParentPtr(Foo, "b", &foo.a);
    _ = another_foo_ptr;
}

// error
// backend=stage2
// target=native
//
// :8:29: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
// :1:13: note: struct declared here