https://issues.dlang.org/show_bug.cgi?id=24720
--- Comment #2 from RazvanN <[email protected]> --- (In reply to RazvanN from comment #1) > The issue has nothing to do with __traits(getMember). It's the alias that's > the problem: > > struct T > { > void myFun(int x) {} > } > T instance; > > void test() > { > alias fun = instance.myFun; > fun(10); // error: instance required > } > > The problem is that you cannot alias an expression, only symbols or types. > The problem here seems to be that the fun alias is accepted, but the > compiler actually aliases to the T.myFun symbol which is not attached to any > particular symbol. Looking at the docs [1] I see that the last runnable line > in the example is commented (alias c = s.j) is commented out with a > "scheduled for deprecation" comment, so I assume that this was discussed at > some point. > > PS: this has been reported in the past multiple times: > https://issues.dlang.org/show_bug.cgi?id=6842 . > > > [1] https://dlang.org/spec/declaration.html#alias-variable > > *** This issue has been marked as a duplicate of issue 6842 *** I meant: "but the compiler actually aliases to the T.myFun symbol which is not attached to any particular instance". Sorry for the confusion. --
