[Issue 2999] Return-type overloading should be error

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 10 09:11:19 UTC 2019


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

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

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

--- Comment #5 from RazvanN <razvan.nitu1305 at 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.

--


More information about the Digitalmars-d-bugs mailing list