www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22111] New: Can't deduce template argument for non-eponymous


          Issue ID: 22111
           Summary: Can't deduce template argument for non-eponymous
                    templated type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.097.0, the following program fails to compile:

template Outer(T)
    struct Inner {}

void func(T)(Outer!T.Inner) {}

void main()
    Outer!int.Inner arg;
    func(arg); // error;

The error message is:

onlineapp.d(11): Error: template `onlineapp.func` cannot deduce function from
argument types `!()(Inner)`, candidates are:
onlineapp.d(6):        `func(T)(Outer!T.Inner)`

If the call to `func` is changed to `func!int(arg)`, compilation succeeds.

Pattern-matching of types in `is()` expressions is also affected by this issue:

static assert(is(typeof(arg) == Outer!int.Inner)); // pass
static assert(is(typeof(arg) == Outer!T.Inner, T)); // fail

Jul 07 2021