[svn] r7076: nemerle/trunk/ncc/typing/Typer.n

malekith svnadmin at nemerle.org
Sun Dec 10 11:23:17 CET 2006


Log:
Forbid casts from void. Also forbid explict casts from void (_ = ... should be used). Patch by Evin Robertson (bug #808).

Author: malekith
Date: Sun Dec 10 11:23:15 2006
New Revision: 7076

Modified:
   nemerle/trunk/ncc/typing/Typer.n

Modified: nemerle/trunk/ncc/typing/Typer.n
==============================================================================
--- nemerle/trunk/ncc/typing/Typer.n	(original)
+++ nemerle/trunk/ncc/typing/Typer.n	Sun Dec 10 11:23:15 2006
@@ -3147,6 +3147,13 @@
           }
         }
 
+        def is_void (t) {
+          match (t.Hint) {
+            | Some (MType.Void) => true
+            | _ => false
+          }
+        }
+
         match (operators) {
           | [(from, single)] =>
             if (single.BuiltinKind is BuiltinMethodKind.ValueTypeConversion)
@@ -3159,7 +3166,8 @@
                                     ConversionKind.MethodCall (sr))
             }
           | [] =>
-            if (is_strange_type (from) || is_strange_type (to)) {
+            if ( (is_strange_type (from) || is_strange_type (to))
+                && !is_void (from) && !is_void (to) ) {
               TExpr.TypeConversion (expr, to, ConversionKind.DownCast ())
             } else if (is_enum (from) && is_enum (to)) {
               TExpr.TypeConversion (expr, to, ConversionKind.IL (local_context.IsChecked))



More information about the svn mailing list