What's the current state of the art for module compilation?

monkyyy crazymonkyyy at gmail.com
Fri Nov 27 20:40:44 UTC 2026


On Friday, 27 November 2026 at 19:55:21 UTC, Walter Bright wrote:
> On 11/24/2026 3:20 AM, David Given wrote:
>> - I was told that using generated .di files with certain 
>> constructs (templates, auto return, something annotation-based 
>> which I forget) doesn't work and produces .di files which will 
>> in turn cause miscompilation and runtime crashes. Can anyone 
>> confirm or deny that?
>
> I'd need to see an example of such a failure. Some experiments 
> I tried don't result in erroneous generation.
>
> But definitely errors will happen if a .d file is changed, and 
> the .di file is not updated accordingly.

Its possible to produce miscompiles with unchanging .d files 
given one of the bugs that expose mutable compile time state, by 
which I dont mean only the extermely useful compiler bug, but the 
useless ones that halt the compiler like any of the template 
optimizations rikki did or `__traits(compiles` order of operation 
bugs.

Since you may rudely remove features heres an acceptable lost: 
mixin("__LINE__") with a -mixin flag gives different results 
based on how many mixin calls have happened; if you were to use 
this int to change the order of a struct fields reordering how 
you passed files to the compiler would give different results.

```d
struct vec2{
   //mixin("static assert(1==1);");
   static if(mixin("__LINE__")%2){
     int x,y;
   } else {
     int y,x;
}}
```

again using `-mixin=mix`; but .di files dont stand a chance in 
hostile examples, the programmer must consider the order of 
operations of templates given complex enough situations.




More information about the Digitalmars-d mailing list