<div dir="ltr"><div>DMD wont compile this. I get an error saying:</div><div>/tmp/test.d(3): Error: need 'this' for 'foo' of type 'int'</div><div>Failed: ["dmd", "-v", "-o-", "/tmp/test.d", "-I/tmp"]</div><div><br></div><div>Is this a bug or is it illegal code?</div><div><br></div><div><div>// Regards</div><div>// Cherry</div></div><div><br></div><div>class Foo {</div><div>  int foo = 42;</div><div>  @foo int bar;</div><div>  this(int frop) {</div><div>    foo = frop;</div><div>  }</div><div>  int getFooAttr() {</div><div>    auto ffff = __traits(getAttributes, this.tupleof[1]);</div><div>    return ffff[0];</div><div>  }</div><div>}</div><div><br></div><div>void main() {</div><div>  Foo f = new Foo(43);</div><div>  f.getFooAttr();</div><div>}</div><div><br></div></div>