diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-27 14:22:36 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-27 14:22:36 -0400 |
| commit | b26da60f2f64d279d6abc682bcef4b74638ae7d3 (patch) | |
| tree | a64569ae02fe62273b4126e7592f80ab1f952381 /compile.c | |
| parent | 0622f758f742420ae8ef6c0cd3296c4ff40f89e0 (diff) | |
Better error message for duplicate fn arg name
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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, ")"); |
