[Issue 22111] New: Can't deduce template argument for non-eponymous templated type

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 7 19:44:59 UTC 2021


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

          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 at puremagic.com
          Reporter: snarwin+bugzilla at 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
---

--


More information about the Digitalmars-d-bugs mailing list