www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13597] New: is(typeof()) works only on second call

https://issues.dlang.org/show_bug.cgi?id=13597

          Issue ID: 13597
           Summary: is(typeof()) works only on second call
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: andre s-e-a-p.de

The output of the coding is:
Reference: Child
false
true
is(typeof()) works only on second call

-----------------

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 "";}
}

--
Oct 10 2014