digitalmars.D.bugs - [Issue 23384] New: Suggest calling matching base class method when
- d-bugmail puremagic.com (40/40) Oct 03 2022 https://issues.dlang.org/show_bug.cgi?id=23384
https://issues.dlang.org/show_bug.cgi?id=23384 Issue ID: 23384 Summary: Suggest calling matching base class method when hidden Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: nick geany.org struct A {} struct B {} class Base { void fun(A a) {} } class Derived : Base { void fun(B b) {} } void main() { Derived d; d.fun(A()); } The above code (rightly IMO) produces this error: overloadhiding.d(18): Error: function `overloadhiding.Derived.fun(B b)` is not callable using argument types `(A)` overloadhiding.d(18): cannot pass argument `A()` of type `A` to parameter `B b` This sometimes gets reported as a suspected compiler bug, e.g. bug 23377 (closed as WONTFIX) or on the forum. After the error message for Derived.fun(A), the compiler should add an informational message when the base class has a match, explaining that match is hidden. That would help the user know the workaround and also make it clear the error is by design. (I had a look but I'm not sure how to implement it). --
Oct 03 2022