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

          Issue ID: 14501
           Summary: template result is reused for equal but non-identical
                    alias arguments
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: [email protected]
          Reporter: [email protected]
            Blocks: 10190

Spin-off from issue 10190.

----
enum a = 1;
enum b = 1;

static assert(__traits(identifier, a) == "a"); /* passes */
static assert(__traits(identifier, b) == "b"); /* passes */

template identifier(alias symbol)
{
    enum identifier = __traits(identifier, symbol);
}

pragma(msg, identifier!a); /* prints "a", ok */
pragma(msg, identifier!b); /* prints "a" too, should print "b" */
----

When printing both identifier!a and identifier!b with pragma(msg,...) it shows
that they're both "a". When the order is switched, they both become "b".
Apparently, the value is reused when it shouldn't be.

--

Reply via email to