www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19766] New: Cannot pass overload set consisting solely of

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

          Issue ID: 19766
           Summary: Cannot pass overload set consisting solely of
                    templated functions as alias
           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

Consider the following code:

// void foo(int) { }
void foo(T : int)(T) { }

void bar(T : string)(T) { }
void baz(T : bool)(T) { }

alias a = foo;
alias a = bar;
alias a = baz;

void test(alias fn)()
{
    fn(0);
    fn(null);
    fn(true);
}

void main() {
    test!a();
}

Result:

onlineapp.d: Error: overload alias `onlineapp.a` forward declaration

If `foo` is a function, as per the comment, I can pass `a` as an overload set
to `test()`, even though the other two functions in the set are templated.
However, since `foo` is also a template, I get an inexplicable error message.

--
Mar 27 2019