[Issue 20586] New: Ambiguous overload set with default parameter gives confusing error message
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Wed Feb 19 09:12:42 UTC 2020
    
    
  
https://issues.dlang.org/show_bug.cgi?id=20586
          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 at puremagic.com
          Reporter: pro.mathias.lang at gmail.com
The following code:
```
void main () nothrow
{
    foo("hello");
}
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)
and:
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
confusing.
--
    
    
More information about the Digitalmars-d-bugs
mailing list