-------------------------------- struct Foo { int a; } Foo foo; alias foo.a b; void main() { b = 5; // <-- Error } -------------------------------- >dmd test.d test.d(11): Error: need 'this' to access member a
This is an enhancement, not "rejects-valid". Because foo.a is an expression, and it is neither type nor symbol. http://d-programming-language.org/declaration.html AliasDeclaration allows type or symbol as the first argument.
(In reply to comment #1) > This is an enhancement, not "rejects-valid". > Because foo.a is an expression, and it is neither type nor symbol. > > http://d-programming-language.org/declaration.html > AliasDeclaration allows type or symbol as the first argument. If foo.a is not a symbol, why does alias foo.a b; compile without an error?
(In reply to comment #2) > If foo.a is not a symbol, why does alias foo.a b; compile without an error? Now compiler treats foo.a as Foo.a, and Foo.a is a symbol. I think this is "accepts-invalid" bug.
*** Issue 9105 has been marked as a duplicate of this issue. ***
*** Issue 8051 has been marked as a duplicate of this issue. ***
*** Issue 6619 has been marked as a duplicate of this issue. ***
*** Issue 9929 has been marked as a duplicate of this issue. ***
*** Issue 14848 has been marked as a duplicate of this issue. ***
*** Issue 20895 has been marked as a duplicate of this issue. ***
*** Issue 24720 has been marked as a duplicate of this issue. ***
> Foo foo; > alias foo.a b; For the next edition, this is an error: https://dlang.org/spec/legacy#alias-instance-member Added in https://github.com/dlang/dmd/pull/15863. Refinement: https://github.com/dlang/dmd/pull/16813.
> alias foo.a b; Note you can instead write: ref b() => foo.a;
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17532 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB