[svn] r7372: nemerle/trunk/ncc: testsuite/negative/cyclic.n typing/StaticTyVar.n

nazgul svnadmin at nemerle.org
Fri Feb 2 22:18:47 CET 2007


Log:
Error on cyclic type parameter constraint

Author: nazgul
Date: Fri Feb  2 22:18:44 2007
New Revision: 7372

Modified:
   nemerle/trunk/ncc/testsuite/negative/cyclic.n
   nemerle/trunk/ncc/typing/StaticTyVar.n

Modified: nemerle/trunk/ncc/testsuite/negative/cyclic.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/cyclic.n	(original)
+++ nemerle/trunk/ncc/testsuite/negative/cyclic.n	Fri Feb  2 22:18:44 2007
@@ -1,3 +1,11 @@
+class Bug854
+{
+  public Foo[T](x : T) : void where T : T { // E: cyclic constraint on type variable T
+        _ = x.Foo()
+  }
+}
+
+
 class A : B {} // E: type definition for `A' is cyclic
 class B : A {}
 
@@ -5,3 +13,5 @@
   interface I {
   }
 }
+
+

Modified: nemerle/trunk/ncc/typing/StaticTyVar.n
==============================================================================
--- nemerle/trunk/ncc/typing/StaticTyVar.n	(original)
+++ nemerle/trunk/ncc/typing/StaticTyVar.n	Fri Feb  2 22:18:44 2007
@@ -136,6 +136,10 @@
             (special & ~GenericParameterAttributes.NotNullableValueTypeConstraint))
         Message.Error ("`struct' generic constraint cannot be used together with `class' or `new ()'");
 
+      foreach (TyVarRef (tv) in subtype)
+        when (tv.Equals (this)) 
+          Message.Error ("cyclic constraint on type variable " + this.ToString ());
+        
       this.special = special;
       Constraints = subtype;
     }



More information about the svn mailing list