www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18520] New: Different delegates can be aliased to the same

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

          Issue ID: 18520
           Summary: Different delegates can be aliased to the same name
                    multiple times
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: monkeyworks12 hotmail.com

The following code compiles with DMD 2.070.2 and prints 0 three times:

alias f = (int n) => 0;
alias f = (char c) => 'a';
alias f = (bool b) => false;

void main()
{
    import std.stdio;
    writeln(f(int.init));  //Prints 0
    writeln(f(char.init)); //Prints 0
    writeln(f(bool.init)); //Prints 0
}

It looks like the int overload is getting called each time.

--
Feb 24 2018