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
Comment #3 by k.hara.pg — 2013-01-21T20:14:05Z
Comment #4 by github-bugzilla — 2013-02-17T18:47:38Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/38bacc17f25b32f41411cb5a1e6b087431073779 fix Issue 1369 - getMember doesn't work for variables in aggregates https://github.com/D-Programming-Language/dmd/commit/6925db01b364e5e053066bf48f73d2b2e7e11632 Merge pull request #1530 from 9rnsr/fix1369 Issue 1369 - getMember doesn't work for variables in aggregates