www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12694] New: Better error message for function call matching


          Issue ID: 12694
           Summary: Better error message for function call matching more
                    than overload
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: bearophile_hugs eml.cc

void bar(float) {}
void bar(double) {}
void bar(real) {}
void main() {

Gives in dmd 2.066alpha:

temp.d(5,8): Error: temp.bar called with argument types (int) matches both:
temp.d(1,6):     temp.bar(float _param_0)
temp.d(3,6):     temp.bar(real _param_0)

I suggest to list all overloads and remove the word "both". I suggest to use a
visual output similar to the one generated fixing Issue 8101 , that gives
errors that look like this:

temp.d(7,5): Error: None of the overloads of 'foo' are callable using argument
types (), candidates are:
temp.d(1,6):        temp.foo(int _param_0)
temp.d(2,6):        temp.foo(int _param_0, int _param_1)

So I suggest an error message like:

temp.d(5,8): Error: call to 'bar' with argument types (int) matches more than
one overload, candidates are:
temp.d(1,6):        test.bar(float _param_0)
temp.d(2,6):        test.bar(double _param_0)
temp.d(3,6):        test.bar(real _param_0)

I think it's useful to improve such error messages because calling functions is
one of the most basic and common operations you do in D.

See also Issue 2789 .

May 02 2014