[Issue 14501] New: template result is reused for equal but non-identical alias arguments
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Apr 25 13:21:09 PDT 2015
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: nobody at puremagic.com
Reporter: ag0aep6g at 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.
--
More information about the Digitalmars-d-bugs
mailing list