Skip to content

Commit dda29e9

Browse files
committed
Python: Add test of keyword argument with same name as positional-only parameter
This is a bit of an edge case, but allowed. Since we currently don't provide information on positional only arguments, we can't do much to solve it right now.
1 parent 56b6441 commit dda29e9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

python/ql/test/experimental/dataflow/coverage/argumentPassing.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,18 @@ def test_mixed():
204204
mixed(**args)
205205

206206

207+
def kwargs_same_name_as_positional_only(a, /, **kwargs):
208+
SINK1(a)
209+
SINK2(kwargs["a"])
210+
211+
@expects(2*2)
212+
def test_kwargs_same_name_as_positional_only():
213+
kwargs_same_name_as_positional_only(arg1, a=arg2) # $ arg1 SPURIOUS: bad1="arg2" MISSING: arg2
214+
215+
kwargs = {"a": arg2} # $ func=kwargs_same_name_as_positional_only SPURIOUS: bad1="arg2" MISSING: arg2
216+
kwargs_same_name_as_positional_only(arg1, **kwargs) # $ arg1
217+
218+
207219
def starargs_only(*args):
208220
SINK1(args[0])
209221
SINK2(args[1])

0 commit comments

Comments
 (0)