[Issue 16181] New: Overloading doesn't consider default arguments with regards to ambiguity
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Fri Jun 17 09:54:14 PDT 2016
    
    
  
https://issues.dlang.org/show_bug.cgi?id=16181
          Issue ID: 16181
           Summary: Overloading doesn't consider default arguments with
                    regards to ambiguity
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b.helyer at gmail.com
The following code compiles:
---
int foo(int a, int b=2) {
    return a + b;
}
int foo(int a) {
    return a;
}
int main() {
    return foo(12);
}
---
The interaction between default arguments and overloading doesn't appear to be
documented, which should be rectified regardless, but isn't this ambiguous? The
above code is rejected by C++ compilers as 'ambiguous', and I would certainly
expect an error to be generated in this particular case.
--
    
    
More information about the Digitalmars-d-bugs
mailing list