aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/compile_time_struct_field.zig
blob: adfcc440e66f200ed2e3b48ee91a4beb6f0bd425 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const S = struct {
    comptime_field: comptime_int = 2,
    normal_ptr: *u32,
};

export fn a() void {
    var value: u32 = 3;
    const comptimeStruct = S{
        .normal_ptr = &value,
    };
    _ = comptimeStruct;
}

// error
//
// :9:10: error: unable to resolve comptime value
// :9:10: note: initializer of comptime-only struct 'tmp.S' must be comptime-known
// :2:21: note: struct requires comptime because of this field