www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20586] New: Ambiguous overload set with default parameter


          Issue ID: 20586
           Summary: Ambiguous overload set with default parameter gives
                    confusing error message
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: pro.mathias.lang gmail.com

The following code:
void main () nothrow

void foo (string)  system nothrow {}
void foo (string)  safe { }

Results in the following error message:
test.d(3): Error: test.foo called with argument types (string) matches both:
test.d(6):     test.foo(string)
test.d(7):     test.foo(string)

But when changing the definition of `foo` to:
void foo (string, float f = 42)  system nothrow {}
void foo (string, int a = 42)  safe { }

We get:
test.d(6): Error: function nope.foo is not nothrow
test.d(1): Error: nothrow function D main may throw

Which, if a user expect overloading to work with different attributes, is

Feb 19 2020