From 3be7a5a8ce4396c878a8f522a5d23628557a4e32 Mon Sep 17 00:00:00 2001 From: Mario Kruselj Date: Tue, 9 Jan 2024 10:31:03 +0100 Subject: [PATCH] Raise error if function has duplicate argument names --- compiler/ksp_compiler.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler/ksp_compiler.py b/compiler/ksp_compiler.py index 714a1de..00d0795 100644 --- a/compiler/ksp_compiler.py +++ b/compiler/ksp_compiler.py @@ -900,6 +900,10 @@ def modifyFunctionDef(self, node, parent_function = None, function_params = None node.locals = set() # a set containing the keys in node.locals_name_subst_dict, but all in lowercase node.used = False + # verify that there are no duplicate argument names in the function definition + if len(set(node.parameters)) > 0: + raise ksp_ast.ParseException(node, "Function contains duplicate argument names!") + # as we visit the function definition, pass along information to nodes further down the tree of the function parameter names params = function_params + node.parameters