Commit d1c5392e authored by Haoyu Bai's avatar Haoyu Bai

fix cdef @locals with default arguments

parent 482d1ac8
......@@ -1673,7 +1673,12 @@ class CFuncDefNode(FuncDefNode):
self.directive_locals.update(env.directives['locals'])
base_type = self.base_type.analyse(env)
# The 2 here is because we need both function and argument names.
name_declarator, type = self.declarator.analyse(base_type, env, nonempty = 2 * (self.body is not None))
if isinstance(self.declarator, CFuncDeclaratorNode):
name_declarator, type = self.declarator.analyse(base_type, env,
nonempty = 2 * (self.body is not None),
directive_locals = self.directive_locals)
else:
name_declarator, type = self.declarator.analyse(base_type, env, nonempty = 2 * (self.body is not None))
if not type.is_cfunction:
error(self.pos,
"Suite attached to non-function declaration")
......
......@@ -5,6 +5,10 @@ import cython
cdef func(x):
return x**2
@cython.locals(x=double)
cdef func_defval(x=0):
return x**2
def test():
"""
>>> isinstance(test(), float)
......
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