Bug 1369 – Unable to find 'this' in __traits(getMember)
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2007-07-24T06:33:00Z
Last change time
2013-02-17T19:03:54Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
reiner.pope
Comments
Comment #0 by reiner.pope — 2007-07-24T06:33:49Z
the following code fails to compile.
class Foo
{
Bar impl;
void foo()
{
__traits(getMember, impl, "func")(); // line 7
}
}
class Bar { void func() { } }
---
The error occurs on line 7: "need 'this' to access member impl"
The code compiles if you replace line 7 with
__traits(getMember, this.impl, "func")();
or
(mixin("impl.func"))();
Comment #1 by andrej.mitrovich — 2012-12-01T15:50:54Z
The error is now worse:
test.d(8): Error: type Bar is not an expression
Comment #2 by andrej.mitrovich — 2013-01-09T15:31:01Z