From b26da60f2f64d279d6abc682bcef4b74638ae7d3 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 27 Sep 2024 14:22:36 -0400 Subject: Better error message for duplicate fn arg name --- compile.c | 4 ++++ 1 file changed, 4 insertions(+) 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, ")"); -- cgit v1.2.3