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

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

// error
//
// :11:41: error: field 'b' has index '1' but pointer value is index '0' of struct 'tmp.Foo'
// :1:13: note: struct declared here