Skip to content

Commit

Permalink
Improve error messages for function calls with duplicate arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
0npv527yh9 committed Oct 23, 2023
1 parent f5748b7 commit 1e4859a
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/simpleChecker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,11 @@ let rec resolve_with_rec sub v_set k t =
) t'

let process_call ~loc lkp ctxt { callee; arg_names; _ } =
let sorted_args = List.fast_sort String.compare arg_names in
let rec find_dup l = match l with
| [_]
| [] -> false
| h::h'::_ when h = h' -> true
| _::t -> find_dup t
in
if find_dup sorted_args then
failwith "Duplicate variable names detected";
match find_opt_duplicate_vars arg_names with
| Some v ->
Locations.raise_errorf ~loc "Duplicate arguments in function %s call: %s" callee v
| _ -> ();

let { arg_types_v; ret_type_v } =
try
StringMap.find callee ctxt.fenv
Expand Down

0 comments on commit 1e4859a

Please sign in to comment.