aboutsummaryrefslogtreecommitdiff
path: root/test/cases/compile_errors/compile_time_struct_field.zig
blob: 8ca502f645a03e2ef25aeb67d1db91390094496a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
// backend=stage2
// target=native
//
// 9:6: error: unable to resolve comptime value
// 9:6: note: initializer of comptime only struct must be comptime-known