Confusion about comptime vs runtime evaluation

In the past, this would compile:

const foo = false;
if(foo) @compileError("bar");

It doesn’t anymore. Unless explicitly marked as comptime, no matter how obvious it is, Zig will assume it is runtime-known. In the example, it will compile the true branch of the if statement, and trigger the compile error.

1 Like