[Issue 2999] Return-type overloading should be error

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 14 21:47:17 PDT 2014


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

hsteoh at quickfur.ath.cx changed:

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

--- Comment #4 from hsteoh at 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.)

--


More information about the Digitalmars-d-bugs mailing list