Use of @compileError: help locating fault code when compiler panic

sometimes the compiler may panic, especially when compile old code with recent compiler.

put

comptime {
    @compileError("debug");
}

in the main call stack,
if the compile error throw, that means the fault code is after this location in the call stack.
otherwise the compiler panic, that means the fault code is before this location in the call stack.

1 Like

Another trick you can do is to use a debug build of the compiler. In this case it will likely tell you what source code it was analyzing when it panicked.

2 Likes