Thread overview
[Issue 16181] Overloading doesn't consider default arguments with regards to ambiguity
Jun 17, 2016
Danila Letunovskiy
May 10, 2020
Dlang Bot
May 11, 2020
Walter Bright
June 17, 2016
https://issues.dlang.org/show_bug.cgi?id=16181

Danila Letunovskiy <kapblc@mail.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kapblc@mail.ru

--- Comment #1 from Danila Letunovskiy <kapblc@mail.ru> ---
And this Error

int foo(int a, int b=2){
    return a + b;
}

int foo(float a){
    return a;
}

void main() {
    writeln( foo(12) );
}

--
May 10, 2020
https://issues.dlang.org/show_bug.cgi?id=16181

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Luhrel created dlang/dmd pull request #11127 "Fix Issue 16181 - Overloading doesn't consider default arguments with…" fixing this issue:

- Fix Issue 16181 - Overloading doesn't consider default arguments with regards to ambiguity

https://github.com/dlang/dmd/pull/11127

--
May 11, 2020
https://issues.dlang.org/show_bug.cgi?id=16181

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|---                         |INVALID

--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> ---
The default argument is treated as an argument.

While both functions match, then the "least as specialized" rule is applied:

  foo(a) can call foo(int a, int b = 2)

  foo(a, 2) cannot call foo(int a)

Therefore, foo(int a) is selected.

Not a bug.

--