[Issue 15352] New: template arguments matching error with delegates

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Nov 17 07:03:54 PST 2015


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

          Issue ID: 15352
           Summary: template arguments matching error with delegates
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: incsall at gmail.com

struct S(T, T delegate(uint idx) supplier)
{
}

auto make1(T, T delegate(uint idx) supplier)()
{
    enum local = supplier; // allows to avoid an error
    S!(T, local) ret;
    return ret;
}
auto make2(T, T delegate(uint idx) supplier)()
{
    S!(T, supplier) ret; // Error: template instance S!(uint, __dgliteral1)
does not match template declaration S(T, uint delegate(uint idx) supplier)
    return ret;
}

unittest
{
    enum dg = delegate(uint idx) => idx;
    S!(uint, dg) s;
    auto v = make1!(uint, dg)();
    v = make2!(uint, dg)(); // throws compilation error
}

DMD32 D Compiler v2.069.0

--


More information about the Digitalmars-d-bugs mailing list