Commit f5c14c1c authored by Stefan Behnel's avatar Stefan Behnel

prevent DefNode inlining for signatures with kwonly arguments

parent 497e35f9
...@@ -5069,6 +5069,8 @@ class InlinedDefNodeCallNode(CallNode): ...@@ -5069,6 +5069,8 @@ class InlinedDefNodeCallNode(CallNode):
return False return False
if len(func_type.args) != len(self.args): if len(func_type.args) != len(self.args):
return False return False
if func_type.num_kwonly_args:
return False # actually wrong number of arguments
return True return True
def analyse_types(self, env): def analyse_types(self, env):
......
...@@ -72,6 +72,27 @@ def test_defaults(a, b): ...@@ -72,6 +72,27 @@ def test_defaults(a, b):
return a, b, c return a, b, c
return inner(a) return inner(a)
@cython.test_assert_path_exists('//SimpleCallNode')
def test_kwonly_args(a, b):
"""
>>> test_kwonly_args(1, 2)
(1, 2, 123)
"""
def inner(a, b=b, *, c=123):
return a, b, c
return inner(a)
@cython.test_assert_path_exists('//SimpleCallNode')
def test_kwonly_args_missing(a, b):
"""
>>> test_kwonly_args_missing(1, 2)
Traceback (most recent call last):
TypeError: inner() needs keyword-only argument c
"""
def inner(a, b=b, *, c):
return a, b, c
return inner(a)
@cython.test_assert_path_exists('//SimpleCallNode') @cython.test_assert_path_exists('//SimpleCallNode')
def test_starred(a): def test_starred(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