www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14501] New: template result is reused for equal but


          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: nobody puremagic.com
          Reporter: ag0aep6g gmail.com
            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.

Apr 25 2015