Bug 10982 – Misleading diagnostic for missing member function overload: "Error: inout method ... is not callable using a const object"
Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-09-06T15:21:19Z
Last change time
2019-11-08T06:49:13Z
Assigned to
No Owner
Creator
Ali Cehreli
Comments
Comment #0 by acehreli — 2013-09-06T15:21:19Z
The following struct has two functions, one marked as const and the other marked as inout. Note that both calls in main are in error: they lack an argument.
struct S
{
void is_const(int) const
{}
void is_inout(int) inout
{}
}
void main()
{
const s = S();
s.is_const();
s.is_inout();
}
The error message for the first one is correct because it mentions the mismatched argument list:
Error: function deneme.S.is_const (int _param_0) const is not callable using argument types () const
However, the error message for the second call is misleading:
Error: inout method deneme.S.is_inout is not callable using a const object
Ali
Comment #1 by verylonglogin.reg — 2013-09-23T00:57:19Z
Very frustrating as `inout` is not an obvious language feature (I mean all these implicit conversions) and the error will misguide lots of coders.
Comment #2 by nicolas.jinchereau — 2017-09-17T01:54:37Z
still present in 2.075
Comment #3 by acehreli — 2019-11-08T06:49:13Z
Works as expected with 2.088. Now both errors are reported equally:
deneme.d(571): Error: function `deneme.S.is_const(int _param_0) const` is not callable using argument types `() const`
deneme.d(571): missing argument for parameter #1: `int _param_0`
deneme.d(572): Error: function `deneme.S.is_inout(int _param_0) inout` is not callable using argument types `() const`
deneme.d(572): missing argument for parameter #1: `int _param_0`