[Issue 6910] New: __traits(hasMember, "<name>") does not work, if template has alias param
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 8 14:30:34 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6910
Summary: __traits(hasMember, "<name>") does not work, if
template has alias param
Product: D
Version: D2
Platform: x86_64
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: tobias at pankrath.net
--- Comment #0 from Tobias Pankrath <tobias at pankrath.net> 2011-11-08 14:29:58 PST ---
Given this code fragment:
--------------
struct Bag(S...)
{
alias S Types;
}
template Test(alias i, B)
{
void fn() {
foreach(t; B.Types)
{
switch(i) {
case IndexOf!(t, B.Types):
{
pragma(msg, __traits(allMembers, t));
pragma(msg, __traits(hasMember, t, "m"));
break;
}
default: {}
}
}
}
}
struct A
{
int m;
}
void main()
{
int i;
alias Test!(i, Bag!(A)).fn func;
}
----------------------
DMD will output:
----------------------
tuple("m")
false
---------------------
It seems that __traits(hasMember, ..) evaluates to false, despite the fact that
the type
does have a member "m". However if the template Test does not have an alias
parameter, everything will work just fine.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list