www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22862] New: Functions cannot be overloaded on return value


          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 puremagic.com
          Reporter: default_357-line 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.

Mar 08 2022