D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10982 - Misleading diagnostic for missing member function overload: "Error: inout method ... is not callable using a const object"
Summary: Misleading diagnostic for missing member function overload: "Error: inout met...
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-06 15:21 UTC by Ali Cehreli
Modified: 2019-11-08 06:49 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ali Cehreli 2013-09-06 15:21:19 UTC
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 Denis Shelomovskii 2013-09-23 00:57:19 UTC
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 forsaken 2017-09-17 01:54:37 UTC
still present in 2.075
Comment 3 Ali Cehreli 2019-11-08 06:49:13 UTC
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`