> I have a final question which is: shouldn't the compiler be able to see that 
> the output of get_version() is being assigned to a const variable, even if I 
> did not use the intermediate const variable?

The compiler does that, the issue is with the proc itself. Note that the error 
exists even if `get_version_compile_failure` is never called. The body of a 
proc that doesn't have the `{.compileTime.}` pragma is not a compile time 
context, so the compiler doesn't allow `staticExec` there. The left hand side 
of a const assignment is however a compile time context (even when inside a 
proc body), which is why it works.

Theoretically, the compiler could infer `{.compileTime.}` automatically for 
procs that are only called during compile time (like 
`get_version_compile_failure`), but I think it would be confusing since the 
programmer himself/herself can't easily infer that in a large program.

Reply via email to