Commit d1c5392e authored by Haoyu Bai's avatar Haoyu Bai

fix cdef @locals with default arguments

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