Bug 24893 – Member functions passed by AliasTemplateParameter are not callable

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-12-12T02:57:12Z
Last change time
2024-12-13T19:38:51Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
basile-z
Moved to GitHub: dmd#20556 →

Comments

Comment #0 by b2.temp — 2024-12-12T02:57:12Z
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
Comment #1 by b2.temp — 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(); } ```
Comment #2 by robert.schadek — 2024-12-13T19:38:51Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20556 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB