Bug 7623 – Allow aliasing of symbols of an aliased subtype

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-01T15:27:51Z
Last change time
2020-03-21T03:56:33Z
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2012-03-01T15:27:51Z
struct Foo { @property bool isOne() { return true; } } struct Bar { Foo foo; alias foo this; alias isOne isTwo; } void main() { } test.d(10): Error: undefined identifier isOne Essentially I wanted to partially merge two types which had a similar structure, but I still wanted to keep the different APIs. I can use property getters and setters to forward a function, but I thought an alias would help me more by allowing me to alias a symbol that was going to be merged via the alias this feature. So while it's not crucially important, I'm making this a feature request.
Comment #1 by dlang-bugzilla — 2017-07-07T17:39:24Z
Pretty sure this can't work for the same reason `alias foo.isOne isTwo` doesn't work - you can't alias an expression.
Comment #2 by b2.temp — 2019-11-03T21:25:31Z
`alias foo.isOne isTwo` actually works but this is a bug since it's a DotIdentifier expression.
Comment #3 by razvan.nitu1305 — 2019-11-30T09:47:50Z
Closing this as invalid.