www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16021] New: Template constraint bug

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 puremagic.com
          Reporter: eric 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
}

--
May 12 2016