From fd082c20e68e657bcc9936a91d8ffdc966285a4b Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 17 Mar 2024 18:36:08 +0800 Subject: [PATCH] add some cases --- src/vm.cpp | 4 +--- tests/21_functions.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/vm.cpp b/src/vm.cpp index a9605ffb..2bcc7c4f 100644 --- a/src/vm.cpp +++ b/src/vm.cpp @@ -897,9 +897,7 @@ PyObject* VM::vectorcall(int ARGC, int KWARGC, bool op_call){ co->name, "() takes ", decl->args.size(), " positional arguments but ", args.size(), " were given" )); } - if(!kwargs.empty()){ - TypeError(_S(co->name, "() takes no keyword arguments")); - } + if(!kwargs.empty()) TypeError(_S(co->name, "() takes no keyword arguments")); s_data.reset(_base + co_nlocals); int i = 0; // prepare args diff --git a/tests/21_functions.py b/tests/21_functions.py index 82960592..b7d2d621 100644 --- a/tests/21_functions.py +++ b/tests/21_functions.py @@ -119,3 +119,24 @@ def f(a=((1,2),3), b=(4,)): return a, b assert f() == (((1,2),3), (4,)) + +def f(a, b): + return a + b + +try: + f(a=1) + exit(1) +except TypeError: + pass + +try: + f(1) + exit(1) +except TypeError: + pass + +try: + f(1, 2, 3) + exit(1) +except TypeError: + pass