Is this a bug in __traits(hasMember..)?

Robert Clipsham robert at octarineparrot.com
Tue Nov 8 14:17:15 PST 2011


On 08/11/2011 20:09, Tobias Pankrath wrote:
> which is very confusing to me. Guess this is a bug?
>
> Tobias

Looks like a bug to me. This works:
----
struct Bag(S...)
{
     alias S Types;
}

template Test(/*alias i,*/ B)
{
     void fn() {
         foreach(t; B.Types)
         {
             pragma(msg, t.stringof);
             pragma(msg, __traits(allMembers, t));
             pragma(msg, __traits(hasMember, t, "m"));
         }
     }
}

struct A
{
     int m;
}
void main()
{
     /*int i;*/
     alias Test!(/*i,*/ Bag!(A)).fn func;
}
----

But if you uncomment everything I've commented then it fails. Definitely 
worth a bug report when you have time - http://d.puremagic.com/issues/

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list