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

Member functions passed by AliasTemplateParameter are not callable #20556

Open
dlangBugzillaToGithub opened this issue Dec 12, 2024 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

basile-z reported this on 2024-12-12T02:57:12Z

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

Description

The following program should compile successfully:

```
class A
{
    void f(){}
}

class B : A
{
    override void f()
    {
        alias Fun = A.f;
        test!(Fun)(this);
        // same errors
        test!(A.f)(this);
        test!(super.f)(this);
    }
}

void test(alias Fun)(A a)
{
    Fun(a);
    a.Fun();
}

void main()
{
    (new B).f();
} 
```

instead we got the following errors

> /tmp/temp_7F594F16A2D0.d(20,8): Error: function `f` is not callable using argument types `(A)`
/tmp/temp_7F594F16A2D0.d(20,8):        expected 0 argument(s), not 1
/tmp/temp_7F594F16A2D0.d(3,10):        `temp_7F594F16A2D0.A.f()` declared here
/tmp/temp_7F594F16A2D0.d(21,6): Error: no property `Fun` for `a` of type `temp_7F594F16A2D0.A`
/tmp/temp_7F594F16A2D0.d(1,1):        class `A` defined here
/tmp/temp_7F594F16A2D0.d(11,9): Error: template instance `temp_7F594F16A2D0.test!(f)` error instantiating
@dlangBugzillaToGithub
Copy link
Author

b2.temp commented on 2024-12-12T11:34:39Z

A more reasonable test case, with no virtual calls and also no invalid syntax (Fun(a) is not supposed to work in D)

```
class A
{
    final void af(){}
}

class B : A
{
    final void bf()
    {
        alias Fun = A.af;
        test!(Fun)(this);
        // same errors
        test!(A.af)(this);
        test!(super.af)(this);
    }
}

void test(alias Fun)(A a)
{
    a.Fun();
}

void main()
{
    (new B).bf();
}  
```

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

1 participant