Commit 620274bf authored by Stefan Behnel's avatar Stefan Behnel

prevent DefNode inlining for signatures with kwonly arguments

--HG--
extra : transplant_source : %2CJ%21%D7%9F%FD%C0v%C8U%15%3B%B2%C7%23%BF%FC%A4%E8%13
parent 6b075801
......@@ -5069,6 +5069,8 @@ class InlinedDefNodeCallNode(CallNode):
return False
if len(func_type.args) != len(self.args):
return False
if func_type.num_kwonly_args:
return False # actually wrong number of arguments
return True
def analyse_types(self, env):
......
......@@ -72,6 +72,27 @@ def test_defaults(a, b):
return a, b, c
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')
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