aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-27 14:22:36 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-27 14:22:36 -0400
commitb26da60f2f64d279d6abc682bcef4b74638ae7d3 (patch)
treea64569ae02fe62273b4126e7592f80ab1f952381
parent0622f758f742420ae8ef6c0cd3296c4ff40f89e0 (diff)
Better error message for duplicate fn arg name
-rw-r--r--compile.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index c1afaac3..3d8011e2 100644
--- a/compile.c
+++ b/compile.c
@@ -765,10 +765,14 @@ CORD compile_statement(env_t *env, ast_t *ast)
type_t *ret_t = fndef->ret_type ? parse_type_ast(env, fndef->ret_type) : Type(VoidType);
CORD arg_signature = "(";
+ Table_t used_names = {};
for (arg_ast_t *arg = fndef->args; arg; arg = arg->next) {
type_t *arg_type = get_arg_ast_type(env, arg);
arg_signature = CORD_cat(arg_signature, compile_declaration(arg_type, CORD_cat("$", arg->name)));
if (arg->next) arg_signature = CORD_cat(arg_signature, ", ");
+ if (Table$str_get(used_names, arg->name))
+ code_err(ast, "The argument name '%s' is used more than once", arg->name);
+ Table$str_set(&used_names, arg->name, arg->name);
}
arg_signature = CORD_cat(arg_signature, ")");