Commit c28ca950 authored by Robert Bradshaw's avatar Robert Bradshaw

Ticket #241, better error for keywords in cdef functions.

parent 6d6ca164
...@@ -2527,6 +2527,10 @@ class GeneralCallNode(CallNode): ...@@ -2527,6 +2527,10 @@ class GeneralCallNode(CallNode):
self.keyword_args.analyse_types(env) self.keyword_args.analyse_types(env)
if self.starstar_arg: if self.starstar_arg:
self.starstar_arg.analyse_types(env) self.starstar_arg.analyse_types(env)
if self.function.type is not py_object_type:
if hasattr(self.function, 'entry') and not self.function.entry.as_variable:
error(self.pos, "Keyword arguments not allowed in cdef functions.")
else:
self.function = self.function.coerce_to_pyobject(env) self.function = self.function.coerce_to_pyobject(env)
self.positional_args = \ self.positional_args = \
self.positional_args.coerce_to_pyobject(env) self.positional_args.coerce_to_pyobject(env)
......
cdef some_function(x, y):
pass
cdef class A:
cdef some_method(self, x, y=1):
pass
some_function(1, 2)
some_function(1, y=2)
cdef A a = A()
a.some_method(1)
a.some_method(1, 2)
a.some_method(1, y=2)
_ERRORS = u"""
:9:13: Keyword arguments not allowed in cdef functions.
:14:13: Keyword arguments not allowed in cdef functions.
"""
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