[Issue 19104] New: Multiple overload resolution match when using default arguments
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sat Jul 21 09:27:02 UTC 2018
    
    
  
https://issues.dlang.org/show_bug.cgi?id=19104
          Issue ID: 19104
           Summary: Multiple overload resolution match when using default
                    arguments
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: slavo5150 at yahoo.com
import std.stdio;
void print(uint value, uint base = 10)
{
    writeln("uint: ", value);
}
void print(int value, uint base = 10)
{
    writeln("int: ", value);
}
void main()
{
    print(10, 16);
}
Error: onlineapp.print called with argument types (int, int) matches both:
onlineapp.d(3):     onlineapp.print(uint value, uint base = 10u)
and:
onlineapp.d(8):     onlineapp.print(int value, uint base = 10u)
https://run.dlang.io/is/BjwO3N
I don't think the overload is ambiguous here.  `print(10, 16)` should call the
`int` overload, and `print(10u, 16)` should call the `uint` overload.
--
    
    
More information about the Digitalmars-d-bugs
mailing list