Compiler crash on calling non-entry function.
authorRobert Bradshaw <robertwb@math.washington.edu>
Sat, 20 Feb 2010 02:04:56 +0000 (18:04 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Sat, 20 Feb 2010 02:04:56 +0000 (18:04 -0800)
Cython/Compiler/ExprNodes.py
tests/errors/e_callnonfunction.pyx

index 20cc4ca5ad5b5a2732352868547d45b61513e5f4..7d1eccfb9b912364761fa45562aa1e9e72afc38a 100755 (executable)
@@ -2600,7 +2600,14 @@ class SimpleCallNode(CallNode):
                 return
             self.function.entry = entry
             self.function.type = entry.type
-        func_type = self.function_type()
+            func_type = self.function_type()
+        else:
+            func_type = self.function_type()
+            if not func_type.is_cfunction:
+                error(self.pos, "Calling non-function type '%s'" % func_type)
+                self.type = PyrexTypes.error_type
+                self.result_code = "<error>"
+                return
         # Check no. of args
         max_nargs = len(func_type.args)
         expected_nargs = max_nargs - func_type.optional_arg_count
index 17f4bdce6ba492acf3af3c2813f41b25464121d1..0f4c19efa28b0efba68b188cedf74812d23537b5 100644 (file)
@@ -8,7 +8,13 @@ ctypedef struct s:    # FIXME: this might be worth an error ...
     int x
 s()
 
+cdef int x():
+    return 0
+
+x()()
+
 _ERRORS = u"""
 2:1: Calling non-function type 'int'
 5:1: Calling non-function type 'float'
+14:3: Calling non-function type 'int'
 """