On 10.01.20 18:27, berni44 wrote:
This clearly shows, that packageName is only instatiated once at top level although mod0 and mod1 are two different things (at least their stringof produces different results) and therefore should be instantiated twice.

Now I don't know if this is a bug in DMD or I should know something I do not know... Can you help me?

----
import m1 = foo.baz;
import m2 = foo;
alias p = __traits(parent, m1);

pragma(msg, m1.stringof); /* "module baz", ok */
pragma(msg, m2.stringof); /* "module foo", ok */
pragma(msg, p.stringof); /* "package foo", ok */

enum e(alias thing) = thing.stringof;

pragma(msg, e!m1); /* "module baz", ok */
pragma(msg, e!m2); /* "module foo", ok */
pragma(msg, e!p); /* "module foo", wat?? */
----

If you switch the last two lines around, you get "package foo" twice.

The compiler apparently thinks that m2 (module foo) and p (package foo) are the same thing when used as a template argument. So it reuses the previous result.

There's a similar issue with values:

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

Reply via email to