Typeof woes

Marek Janukowicz marek at janukowicz.net
Tue Aug 20 16:42:11 PDT 2013


Given this short program:

class A {

  int i;
  //enum Smth { X };

  void list () {
    foreach( s; __traits(derivedMembers, typeof(this))) {
      alias type = typeof(__traits(getMember, this, s));
    }
  }
}

void main () {
  A a = new A();
  a.list();
}

if I uncomment "enum" line I get compilation error:
aa.d(8): Error: argument Smth to typeof is not an expression

So far it only happened with enums for me, but admittedly I didn't check all 
the possible types out there.

What's even more interesting it's just alias problem, the expression 
"typeof(__traits(getMember, this, s))" might be used eg. in static if even 
for enums.

Is this a bug or do I miss something (again)?

-- 
Marek Janukowicz


More information about the Digitalmars-d-learn mailing list