Why is the error message coming by the end of the compilation?

Ikeran dhasenan at ikeran.org
Fri Apr 13 21:20:26 UTC 2018


On Friday, 13 April 2018 at 20:50:38 UTC, bauss wrote:
> What I'm doing is basically this:
>     static foreach (viewResult; generateViewsResult)
>     {
>       pragma(msg, "Compiling: " ~ viewResult.name);
>       mixin(viewResult.source);
>       pragma(msg, "Compiled: " ~ viewResult.name);
>     }
>
> I would've expect the compiling to be before the error message, 
> but the compiled after the error message.
>
> However it seems like it doesn't do that, but as I can't 
> reproduce it I'm just wondering what causes it.

The compiler is free to examine your source code in any order 
that produces the same artifacts on success and self-consistent 
error messages otherwise. In this case, it evaluated the pragmas 
and the `mixin` in one pass, then the function body in a separate 
pass.

The best way I've found to debug mixins is to pragma(msg) the 
code I wanted to mix in, then insert it myself.


More information about the Digitalmars-d-learn mailing list