blueloveTH 1 год назад
Родитель
Сommit
fd082c20e6
2 измененных файлов с 22 добавлено и 3 удалено
  1. 1 3
      src/vm.cpp
  2. 21 0
      tests/21_functions.py

+ 1 - 3
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

+ 21 - 0
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