[Issue 22862] New: Functions cannot be overloaded on return value alone.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 9 06:08:26 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22862
Issue ID: 22862
Summary: Functions cannot be overloaded on return value alone.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: default_357-line at yahoo.de
If you attempt to write code like this:
int foo() { }
float foo() { }
you get an error: foo conflicts with previous declaration.
Allowing this seems clearly pointless, since overloads that only differ by
return value cannot be differentiated on call, but they *can* be differentiated
by traits, ie. getOverloads. As such, it would be nice if the arbitrary
restriction on overloading functions with the same parameter types was removed.
--
More information about the Digitalmars-d-bugs
mailing list