[Mono-devel-list] gmcs constraint checking error?

Ben Martin benmartin at fourthplanet.net
Tue Jul 27 17:39:31 EDT 2004


I am fairly certain this is an error, but I may also be missing 
something - that happens sometimes... I am doing some work with 
constraints, and so I wrote a simple test case, which fails 
unexpectedly. I checked the spec, and it doesn't seem to violate 
anything there, and I don't see why this error makes sense, so I think 
this is a bug (though, like I said, I have been known to be wrong).

Here is the program:

using System;

class A<T> where T: IComparable  {
}

class B<T, S> where T: IComparable where S: A<T> {
}

class Driver {
  public static void Main()
  {
    B<int, A<int>> b_stuff; // line 12
  }
}

And here is the error I get:

error_test.cs(12) error CS0309: The type `A`1[System.Int32]' must be 
convertible to `A`1[T]' in order to use it as parameter `S' in the 
generic type or method `B`2<T,S>'
Compilation failed: 1 error(s), 0 warnings

I checked the code to see if I could figure out what was wrong, but I 
quickly found myself over my head.

I will put this on bugzilla if somebody can confirm for me this is a 
bug, and I'll even try to fix it if somebody can point me in the right 
direction as to what needs changed. (I tracked it as far as the class 
and interface constraint checks in ConstructedType.CheckConstraints(), 
but after that I get lost trying to understand the code.)



More information about the Mono-devel-list mailing list