www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20821] New: Aliased template method confuses overload

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

          Issue ID: 20821
           Summary: Aliased template method confuses overload resolution
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

struct S {
    int gun()(int i) { return 0; }
    alias fun = gun;
    int fun() { return 1; }
}

static assert(S().fun == 1); // Error

The above code gives the error message 'void has no value'. It seems it
believes I'm referring to gun, while I'm in fact trying to call fun().

If an alias is not used, and gun is called fun instead, the above code works
correctly.

--
May 11 2020