Thread overview |
---|
August 26 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |razvan.nitu1305@gmail.com Resolution|--- |DUPLICATE --- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> --- 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 *** -- |
August 26 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 --- Comment #2 from RazvanN <razvan.nitu1305@gmail.com> --- (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. -- |
August 26 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 Nick Treleaven <nick@geany.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nick@geany.org --- Comment #3 from Nick Treleaven <nick@geany.org> --- > alias fun = instance.myFun; Thanks, should get detected with https://github.com/dlang/dmd/pull/16813. > 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 Walter said we shouldn't add a deprecation for this (probably because if people understood it, it might deprecate correct code): https://github.com/dlang/dmd/pull/15863#issuecomment-1902711081 I should update that comment though. -- |
August 28 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 --- Comment #4 from Manu <turkeyman@gmail.com> --- Sorry, but what is this a duplicate of? It's definitely not fixed... -- |
August 28 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 --- Comment #5 from RazvanN <razvan.nitu1305@gmail.com> --- (In reply to Manu from comment #4) > Sorry, but what is this a duplicate of? > It's definitely not fixed... It's a duplicate of issue 6842: https://issues.dlang.org/show_bug.cgi?id=6842 which indeed is not fixed. -- |
August 28 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 --- Comment #6 from Manu <turkeyman@gmail.com> --- Oh sorry, I thought I saw that it was closed too. My mistake! -- |
August 28 [Issue 24720] Can't alias __traits(getMember) | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24720 --- Comment #7 from RazvanN <razvan.nitu1305@gmail.com> --- No worries! -- |
Copyright © 1999-2021 by the D Language Foundation