Bug 6842 – Can't use alias of instance member

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-10-22T18:14:44Z
Last change time
2024-12-13T17:56:38Z
Assigned to
No Owner
Creator
Nick Sabalausky
See also
https://issues.dlang.org/show_bug.cgi?id=16123, https://issues.dlang.org/show_bug.cgi?id=3452
Moved to GitHub: dmd#17532 →

Comments

Comment #0 by bus_dbugzilla — 2011-10-22T18:14:44Z
-------------------------------- 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
Comment #1 by k.hara.pg — 2011-10-22T22:28:33Z
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.
Comment #2 by timon.gehr — 2011-10-23T01:10:41Z
(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?
Comment #3 by k.hara.pg — 2011-10-23T02:21:48Z
(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.
Comment #4 by andrej.mitrovich — 2012-12-02T11:29:39Z
*** Issue 9105 has been marked as a duplicate of this issue. ***
Comment #5 by andrej.mitrovich — 2012-12-02T11:30:55Z
*** Issue 8051 has been marked as a duplicate of this issue. ***
Comment #6 by andrej.mitrovich — 2012-12-02T11:31:08Z
*** Issue 6619 has been marked as a duplicate of this issue. ***
Comment #7 by andrej.mitrovich — 2013-04-13T14:08:20Z
*** Issue 9929 has been marked as a duplicate of this issue. ***
Comment #8 by andrej.mitrovich — 2016-08-28T19:15:42Z
*** Issue 14848 has been marked as a duplicate of this issue. ***
Comment #9 by john.michael.hall — 2023-02-08T20:17:15Z
*** Issue 20895 has been marked as a duplicate of this issue. ***
Comment #10 by razvan.nitu1305 — 2024-08-26T08:19:16Z
*** Issue 24720 has been marked as a duplicate of this issue. ***
Comment #11 by nick — 2024-08-26T11:13:51Z
> 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.
Comment #12 by nick — 2024-08-28T11:36:54Z
> alias foo.a b; Note you can instead write: ref b() => foo.a;
Comment #13 by robert.schadek — 2024-12-13T17:56:38Z
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