Is this a bug?

Eric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 15 10:13:56 PDT 2016


   1 alias J = const C;
   2
   3 void main(string[] args)
   4 {
   5     J a = new C();
   6     I!(J) i = a;
   7 }
   8
   9 interface I(V) { }
  10
  11 class F(V) if (is(V : I!(V))) { }
  12
  13 class C : I!(J)
  14 {
  15     F!(J) m;
  16 }

The above code gives the following compile error:
Error:
template instance F!(const(C)) does not match template 
declaration F(V) if (is(V : I!V))
on line 15.

If I change line 1 to "alias J = C;" the code will compile.  The 
problem seems to be
the template constraint on line 11.  I think the constraint says, 
"If V can be automatically
converted to I!(V) then this template can be used".  However, 
line 6 does not give
an error, and it seems to be automaticaly converting J to I!(J).

-Eric


More information about the Digitalmars-d-learn mailing list