diff sema/TypeCheck.d @ 193:658178183018

Added error message for the case of calling a function pointer with wrong parameter count.
author Anders Johnsen <skabet@gmail.com>
date Fri, 25 Jul 2008 15:31:16 +0200
parents e799db8d9cb0
children
line wrap: on
line diff
--- a/sema/TypeCheck.d	Fri Jul 25 15:00:54 2008 +0200
+++ b/sema/TypeCheck.d	Fri Jul 25 15:31:16 2008 +0200
@@ -218,7 +218,15 @@
                 }
             }
             else if (iden.type.isCallable)
+            {
                 function_type = iden.type.asCallable();
+                if (exp.args.length != function_type.params.length)
+                {
+                    messages.report(CannotCallMethod, exp.loc)
+                        .arg(iden.type.toString)
+                        .arg(exp.callerType.toString);
+                }
+            }
             else assert(0, "Should not happen");
 
             foreach (i, arg; exp.args)
@@ -421,13 +429,14 @@
         Symbol[] possible;
         Symbol perfect;
 
+        bool per, work;
         foreach (s ; available)
         {
             if (s.type.asFunction.params.length < arg_list.length)
                 continue;
 
-            bool per = true;
-            bool work = true;
+            per = true;
+            work = true;
 
             foreach (i, arg; arg_list)
             {