| Thread overview | |||||
|---|---|---|---|---|---|
|
November 08, 2011 Is this a bug in __traits(hasMember..)? | ||||
|---|---|---|---|---|
| ||||
Please take a look at this code
--------------------
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;
}
-----------------
If I compile this, DMD will print
------------------
dmd test.d
tuple("m")
false
------------------
which is very confusing to me. Guess this is a bug?
Tobias
| ||||
November 08, 2011 Re: Is this a bug in __traits(hasMember..)? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tobias Pankrath | 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/ | |||
November 08, 2011 Re: Is this a bug in __traits(hasMember..)? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Robert Clipsham | http://d.puremagic.com/issues/show_bug.cgi?id=6910 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply