[Issue 15318] Templates not emitted for two "partial cycles"

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Nov 12 13:40:57 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15318

--- Comment #2 from David Nadlinger <code at klickverbot.at> ---
(In reply to Martin Nowak from comment #1)
> In both of the compilations there is a root and a non-root module
> instantiating bar!5. Now unfortunately the compiler decides both times that
> the non-root module should do it.

That is correct.

> This problem would be solved by my proposal to define a global order for who
> is responsible to instantiate a template, by choosing the module with the
> lexicographically smaller module name.
> https://github.com/D-Programming-Language/dmd/pull/4384#discussion_r29910422
> https://issues.dlang.org/show_bug.cgi?id=14431#c12
> 
> This would establish a stable order between B and C, and no matter how you
> compile them, B gets to instantiate the template.

At first glance, it seems as if this should work. However, I would need to
think about it in more detail to be sure that the approach doesn't implicitly
introduce any new edges in the module dependency graph that would break
incremental compilation.

> An intermediate workaround for your problem is to use the -allinst switch […]

I'd say a much better workaround would be to just remove the clearly faulty
"optimization" from DMD until we have a solid strategy to replace it with. In
fact, Weka is currently using a lightweight fork of upstream LDC with the code
mentioned in the original report patched out, and it has resolved all the
related issues.

--


More information about the Digitalmars-d-bugs mailing list