Commit 5dbb42b3 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix bad self argument crash in cpdef methods (#165)

--HG--
rename : tests/bugs/missing_self_in_cpdef_method_T165.pyx => tests/errors/missing_self_in_cpdef_method_T165.pyx
parent 11ed9af8
...@@ -1337,7 +1337,12 @@ class CFuncDefNode(FuncDefNode): ...@@ -1337,7 +1337,12 @@ class CFuncDefNode(FuncDefNode):
self.entry.inline_func_in_pxd = self.inline_in_pxd self.entry.inline_func_in_pxd = self.inline_in_pxd
self.return_type = type.return_type self.return_type = type.return_type
if self.overridable and len(self.args) > 0: if self.overridable and not env.is_module_scope:
if len(self.args) < 1 or not self.args[0].type.is_pyobject:
# An error will be produced in the cdef function
self.overridable = False
if self.overridable:
import ExprNodes import ExprNodes
py_func_body = self.call_self_node(is_module_scope = env.is_module_scope) py_func_body = self.call_self_node(is_module_scope = env.is_module_scope)
self.py_func = DefNode(pos = self.pos, self.py_func = DefNode(pos = self.pos,
......
...@@ -3,3 +3,6 @@ cdef class A: ...@@ -3,3 +3,6 @@ cdef class A:
cpdef a(int not_self): cpdef a(int not_self):
pass pass
_ERRORS = u"""
3:10: Self argument (int) of C method 'a' does not match parent type (A)
"""
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment