Hmm, yes I think you are right with that.
@compileError triggers when it is reached during semantic analysis, but comptime / compile time execution of functions also happens during semantic analysis.
From:
After we have generated all of our ZIR, then we have
Sema
. This is the heart of the compiler – it’s the stage that performs semantic analysis, which includes type checking, comptime code execution, most error messages, etc.Sema
interprets the ZIR whichAstGen
emitted and turns it into AIR (Analyzed Intermediate Representation), a much more simple and low-level IR which is sent to the code generator.CodeGen
is actually interleaved withSema
: after a function is semantically analyzed, it’s immediately sent to the code generator.
For the rest read the linked post. So I think I would rephrase:
I think it runs whatever comptime parts there are within the function (if there are any).
Not completely sure, that is just my best guess at the moment.
I think for a better answer I would have to dig into the implementation myself. (Which I want to do eventually, but haven’t done yet)