[Issue 16021] New: Template constraint bug

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu May 12 09:11:35 PDT 2016


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

          Issue ID: 16021
           Summary: Template constraint bug
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: eric at makechip.com

is(T : A!T) tells if T can automatically be converted to A!T.  The
last line below is doing just that, yet the template constraint does not work.

class A(T) if (is(T : A!T))
{
}

// if (is(T : A!T)) gives this error:
// Error: template instance x.A!(B) does not match
//        template declaration A(T) if (is(T : A!T))
//        while looking for match for A!(B)

class B : A!(B)
{
}

void main(string[] args)
{
    B b = new B();
    A!B a = b; // compiles fine
}

--


More information about the Digitalmars-d-bugs mailing list