[svn] r7040: nemerle/trunk/ncc: generation/Typer4.n testsuite/negative/void-parm2.n

malekith svnadmin at nemerle.org
Mon Dec 4 12:37:11 CET 2006


Log:
Check for void in constructors.

Author: malekith
Date: Mon Dec  4 12:37:11 2006
New Revision: 7040

Modified:
   nemerle/trunk/ncc/generation/Typer4.n
   nemerle/trunk/ncc/testsuite/negative/void-parm2.n

Modified: nemerle/trunk/ncc/generation/Typer4.n
==============================================================================
--- nemerle/trunk/ncc/generation/Typer4.n	(original)
+++ nemerle/trunk/ncc/generation/Typer4.n	Mon Dec  4 12:37:11 2006
@@ -208,6 +208,17 @@
         Message.Error (e.loc, "`throw' is not allowed here");
     }
 
+    NoDeepVoid (expr : TExpr, t : TyVar) : void
+    {
+      match (t.Fix ()) {
+        | Class (_, tp) =>
+          foreach (t in tp)
+            when (t.Fix ().Equals (InternalType.Void))
+              Message.Error (expr.loc, $ "cannot use `void' in generic specifier of $expr");
+        | _ => {}
+      }
+    }
+
     Throws (expr : TExpr, allow_try = false, is_top = false) : bool
     {
       log (STV, expr.loc, $ "{ throws: top=$is_top $(expr.GetType()) $expr");
@@ -554,7 +565,9 @@
             else
               TExpr.DefValIn (decl, e1, e2)
             
-          | Call (ImplicitValueTypeCtor, [], _) => null
+          | Call (ImplicitValueTypeCtor, [], _) =>
+            NoDeepVoid (expr, expr.Type);
+            null
           
           | Call (OpCode ("==.ref"), [p1, p2], _)
           | Call (OpCode ("!=.ref"), [p1, p2], _)
@@ -595,8 +608,10 @@
                   
                   meth
                   
-                | Base (meth)
-                | StaticRef (_, meth is IMethod, _) => meth
+                | Base (meth) => meth
+                | StaticRef (from, meth is IMethod, _) => 
+                  NoDeepVoid (func, from);
+                  meth
                 | _ => Util.ice ($ "invalid thing called $func")
               }
 

Modified: nemerle/trunk/ncc/testsuite/negative/void-parm2.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/negative/void-parm2.n	(original)
+++ nemerle/trunk/ncc/testsuite/negative/void-parm2.n	Mon Dec  4 12:37:11 2006
@@ -15,4 +15,11 @@
     mutable q = 7;
     System.Console.WriteLine ("{0}", q++); // E: void is not a subtype of System.Object
   }
+
+  public foo() : void
+  {
+
+    _ = System.Collections.Generic.List.[void] () ; // E: cannot use `void' in generic specifier of System.Collections.Generic.List\[void\]
+    _ = System.Collections.Generic.List.[System.Void] () ; // E: cannot use `void' in generic specifier of System.Collections.Generic.List\[void\]
+  }
 }



More information about the svn mailing list