[svn] r5932: nemerle/trunk/ncc: hierarchy/TypeBuilder.n testsuite/negative/small-variant.n typing/TyVarEnv...

nazgul svnadmin at nemerle.org
Mon Nov 14 19:04:36 CET 2005


Log:
Do not allow duplicate constraints on generic parameters

Author: nazgul
Date: Mon Nov 14 19:04:25 2005
New Revision: 5932

Modified:
   nemerle/trunk/ncc/hierarchy/TypeBuilder.n
   nemerle/trunk/ncc/testsuite/negative/small-variant.n
   nemerle/trunk/ncc/typing/TyVarEnv.n

Modified: nemerle/trunk/ncc/hierarchy/TypeBuilder.n
==============================================================================
--- nemerle/trunk/ncc/hierarchy/TypeBuilder.n	(original)
+++ nemerle/trunk/ncc/hierarchy/TypeBuilder.n	Mon Nov 14 19:04:25 2005
@@ -1007,7 +1007,7 @@
     match (pt_tydecl) {
       | PT.TopDeclaration.VariantOption (members) =>
         unless (Util.is_capitalized (name)) {
-          Message.Error (loc, "variant options names must start with capital letters")
+          Message.Error (loc, "variant options' names must start with capital letter")
         };
       
         foreach (mem in members)
@@ -1017,7 +1017,7 @@
       | _ => ()
     };
 
-    self_type = MType.Class (this, List.Map (this.typarms, fun (x) { MType.TyVarRef (x) }));
+    self_type = MType.Class (this, this.typarms.Map (MType.TyVarRef (_)));
 
     foreach (tb in this.contained_types)
       Util.locate (tb.loc, tb.make_tyenvs ());

Modified: nemerle/trunk/ncc/testsuite/negative/small-variant.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/small-variant.n	(original)
+++ nemerle/trunk/ncc/testsuite/negative/small-variant.n	Mon Nov 14 19:04:25 2005
@@ -1,5 +1,5 @@
 variant Foo {
   | Bar         // OK
-  | baz         // E: variant options names must start with capital letters
+  | baz         // E: variant options' names must start with capital letter
 }
 

Modified: nemerle/trunk/ncc/typing/TyVarEnv.n
==============================================================================
--- nemerle/trunk/ncc/typing/TyVarEnv.n	(original)
+++ nemerle/trunk/ncc/typing/TyVarEnv.n	Mon Nov 14 19:04:25 2005
@@ -395,7 +395,12 @@
               | <[ @struct ]> => special |= GenericParameterAttributes.NotNullableValueTypeConstraint;
               | <[ @new ]> => special |= GenericParameterAttributes.DefaultConstructorConstraint;
               | _ =>
-                subtype = tenv.MonoBind (env, curtc, c.ty, check_parms) :: subtype;
+                def ty = tenv.MonoBind (env, curtc, c.ty, check_parms);
+                if (subtype.Contains (ty))
+                  Message.Error ($"constraint `$ty' is already declared for $tv");
+                else
+                  subtype = ty :: subtype;
+                
             }
             constraints [tv.id] = (special, subtype);
             



More information about the svn mailing list