__traits(getMember) works only the second time
    andre via Digitalmars-d-learn 
    digitalmars-d-learn at puremagic.com
       
    Fri Oct 10 00:08:27 PDT 2014
    
    
  
Hi,
by executing the example source code,
following output is returned:
Reference: Child
false
true
At first "childStr" is not found, then it is found?
Is this a bug?
Kind regards
André
-----------------
module app;
import test;
class Child : Parent
{
   mixin ComponentTemplate;
   @property string childStr(){return "";}
}
void main()
{
   auto child = new Child();
   child.getParameters();
}
-----------------
module test;
template Params(this MyType)
{
   string[] Params()
   {
     pragma(msg, "Reference: " ~ MyType.stringof);
     pragma(msg, is(typeof(__traits(getMember, MyType, 
"childStr"))));
     pragma(msg, is(typeof(__traits(getMember, MyType, 
"childStr"))));
     return [];
   }
}
mixin template ComponentTemplate()
{
   private enum parameters = Params!(typeof(this));
	
   string[] getParameters()
   {
     return parameters;
   }
}
class Parent
{
   @property string parentStr(){return "";}
}
    
    
More information about the Digitalmars-d-learn
mailing list