Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"alias this" ignored for aliased methods #18779

Open
dlangBugzillaToGithub opened this issue Feb 21, 2014 · 2 comments
Open

"alias this" ignored for aliased methods #18779

dlangBugzillaToGithub opened this issue Feb 21, 2014 · 2 comments

Comments

@dlangBugzillaToGithub
Copy link

Vladimir Panteleev (@CyberShadow) reported this on 2014-02-21T21:35:56Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=12222

CC List

  • RazvanN

Description

///// test.d /////
struct S
{
    void f() {}
}

struct W
{
    S s;
    alias s this;
    alias f = s.f;
}

void main()
{
    W w;
    w.f();
}
//////////////////

Compiler complains:

test.d(16,2): Error: this for f needs to be type S not type W

However, there is an "alias this" it W to S which should allow the method to be called with S as the "this" type.
@dlangBugzillaToGithub
Copy link
Author

razvan.nitu1305 commented on 2018-11-05T11:41:48Z

Why would you even do that? Isn't the alias this enough?

@dlangBugzillaToGithub
Copy link
Author

dlang-bugzilla (@CyberShadow) commented on 2018-12-27T20:56:45Z

I don't remember for certain, but I think it is so that f can be passed as an alias parameter to a method of W.

@thewilsonator thewilsonator added the Feature:alias alias and alias this label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants