From 0a0e72a79b9c4f3608b0a520590e42ed4247eefc Mon Sep 17 00:00:00 2001 From: Robert Bradshaw Date: Fri, 19 Feb 2010 18:04:56 -0800 Subject: [PATCH] Compiler crash on calling non-entry function. --- Cython/Compiler/ExprNodes.py | 9 ++++++++- tests/errors/e_callnonfunction.pyx | 6 ++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 20cc4ca5..7d1eccfb 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -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 = "" + return # Check no. of args max_nargs = len(func_type.args) expected_nargs = max_nargs - func_type.optional_arg_count diff --git a/tests/errors/e_callnonfunction.pyx b/tests/errors/e_callnonfunction.pyx index 17f4bdce..0f4c19ef 100644 --- a/tests/errors/e_callnonfunction.pyx +++ b/tests/errors/e_callnonfunction.pyx @@ -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' """ -- 2.26.2