D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7623 - Allow aliasing of symbols of an aliased subtype
Summary: Allow aliasing of symbols of an aliased subtype
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-01 15:27 UTC by Andrej Mitrovic
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Andrej Mitrovic 2012-03-01 15:27:51 UTC
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 Vladimir Panteleev 2017-07-07 17:39:24 UTC
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 basile-z 2019-11-03 21:25:31 UTC
`alias foo.isOne isTwo` actually works but this is a bug since it's a DotIdentifier expression.
Comment 3 RazvanN 2019-11-30 09:47:50 UTC
Closing this as invalid.