July 15, 2014
https://issues.dlang.org/show_bug.cgi?id=2999

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #4 from hsteoh@quickfur.ath.cx ---
Wow this one is pretty funny:
-----
short foo() { return 1; }
int foo() { return 2; }
void main() {
    short s = foo();
    int i = foo();

    import std.stdio;
    writeln(s);
    writeln(i);
}
-----

Compiler output:
-----
test.d(4): Error: test.foo called with argument types () matches both:
test.d(1):     test.foo()
and:
test.d(2):     test.foo()
test.d(5): Error: test.foo called with argument types () matches both:
test.d(1):     test.foo()
and:
test.d(2):     test.foo()
-----

That's hilarious, since there's no way you can actually disambiguate between them! (Not that I know of, anyway.)

--
September 10
https://issues.dlang.org/show_bug.cgi?id=2999

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WORKSFORME

--- Comment #5 from RazvanN <razvan.nitu1305@gmail.com> ---
Running the second examples now yields:

1
2

This is the expected behavior.

The first example still compiles. I assume that this is necessary in order to facilitate the compilation of the second example (for consistency reasons). In D, you have to implement both foo methods, so you must have the ability of overloading based on return type. Note that instantiating a C and calling foo will output an error.

C c = new C;
writeln(c.foo());    // foo called with arguments () matches both definitions

Closing as WORKSFORME.

--