Files
zig/test/cases/compile_errors/compile_time_struct_field.zig
2024-09-01 17:31:00 +03:00

20 lines
379 B
Zig

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