From 33129800f4c2b3767d4d81858d6318b684587f0c Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 21 May 2025 15:07:16 +0200 Subject: [PATCH 1/3] rework function apply error messages --- compiler/ml/typecore.ml | 145 +++++++++++++++--- compiler/ml/typecore.mli | 3 +- .../expected/arity_mismatch.res.expected | 7 +- .../expected/arity_mismatch2.res.expected | 7 +- .../expected/fun_return_poly1.res.expected | 4 +- .../expected/fun_return_poly2.res.expected | 5 +- .../method_arity_mismatch.res.expected | 7 +- .../expected/missing_label.res.expected | 4 +- .../expected/missing_labels.res.expected | 5 +- .../expected/moreArguments1.res.expected | 7 +- .../expected/moreArguments2.res.expected | 7 +- .../expected/moreArguments3.res.expected | 7 +- .../expected/moreArguments4.res.expected | 7 +- .../expected/moreArguments5.res.expected | 7 +- .../non_function_uncurried_apply.res.expected | 4 +- .../expected/opt_args_arity.res.expected | 7 +- .../expected/partial_app.res.expected | 7 +- .../expected/primitives3.res.expected | 7 +- .../expected/primitives4.res.expected | 4 +- .../expected/recursive_type.res.expected | 8 +- .../uncurried_wrong_label.res.expected | 5 +- .../expected/warnings1.res.expected | 7 +- 22 files changed, 207 insertions(+), 64 deletions(-) diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index bb96310964..69e9b2309c 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -75,7 +75,8 @@ type error = | Unknown_literal of string * char | Illegal_letrec_pat | Empty_record_literal - | Uncurried_arity_mismatch of type_expr * int * int + | Uncurried_arity_mismatch of + type_expr * int * int * Asttypes.Noloc.arg_label list | Field_not_optional of string * type_expr | Type_params_not_supported of Longident.t | Field_access_on_dict_type @@ -3466,7 +3467,10 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : ( funct.exp_loc, env, Uncurried_arity_mismatch - (funct.exp_type, arity, List.length sargs) )); + ( funct.exp_type, + arity, + List.length sargs, + sargs |> List.map (fun (a, _) -> to_noloc a) ) )); arity | None -> max_int in @@ -3482,7 +3486,10 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) : ( funct.exp_loc, env, Uncurried_arity_mismatch - (funct.exp_type, required_args + newarity, required_args) ))); + ( funct.exp_type, + required_args + newarity, + required_args, + sargs |> List.map (fun (a, _) -> to_noloc a) ) ))); let new_t = if fully_applied then new_t else @@ -4250,17 +4257,17 @@ let report_error env ppf error = accepts_count (if accepts_count == 1 then "argument" else "arguments") | _ -> - fprintf ppf "@[@[<2>This expression has type@ %a@]@ %s@]" type_expr typ - "It is not a function.") + fprintf ppf + "@[@[<2>This can't be called, it's not a function.@]@,\ + It has type: %a@]" + type_expr typ) | Apply_wrong_label (l, ty) -> let print_label ppf = function - | Noloc.Nolabel -> fprintf ppf "without label" - | l -> fprintf ppf "with label %s" (prefixed_label_name l) + | Noloc.Nolabel -> fprintf ppf "an unlabelled argument at this position" + | l -> fprintf ppf "the argument @{%s@}" (prefixed_label_name l) in - fprintf ppf - "@[@[<2>The function applied to this argument has type@ %a@]@.This \ - argument cannot be applied %a@]" - type_expr ty print_label l + fprintf ppf "@[@[<2>This function does not take %a.@]@,It has type: %a@]" + print_label l type_expr ty | Label_multiply_defined {label; jsx_component_info = Some jsx_component_info} -> fprintf ppf @@ -4410,14 +4417,114 @@ let report_error env ppf error = fprintf ppf "Empty record literal {} should be type annotated or used in a record \ context." - | Uncurried_arity_mismatch (typ, arity, args) -> - fprintf ppf "@[@[<2>This function has type@ %a@]" type_expr typ; - fprintf ppf - "@ @[It is applied with @{%d@} argument%s but it requires \ - @{%d@}.@]@]" - args - (if args = 1 then "" else "s") - arity + | Uncurried_arity_mismatch (typ, arity, args, sargs) -> + (* We need: + - Any arg that's required but isn't passed + - Any arg that is passed but isn't in the fn definition (optional or labelled) + - Any mismatch in the number of unlabelled args (since all of them are required) + *) + let rec collect_args ?(acc = []) typ = + match typ.desc with + | Tarrow (arg, _, next, _, _) -> collect_args ~acc:(arg :: acc) next + | _ -> acc + in + let args_from_type = collect_args typ in + + (* Unlabelled arg counts *) + let args_from_type_unlabelled = + args_from_type + |> List.filter (fun arg -> arg = Noloc.Nolabel) + |> List.length + in + let sargs_unlabelled = + sargs |> List.filter (fun arg -> arg = Noloc.Nolabel) |> List.length + in + let mismatch_in_unlabelled_args = + args_from_type_unlabelled <> sargs_unlabelled + in + + (* Required args that aren't passed *) + let required_args = + args_from_type + |> List.filter_map (fun arg -> + match arg with + | Noloc.Labelled n -> Some n + | Optional _ | Nolabel -> None) + in + let passed_named_args = + sargs + |> List.filter_map (fun arg -> + match arg with + | Noloc.Labelled n | Optional n -> Some n + | Nolabel -> None) + in + let missing_required_args = + required_args + |> List.filter (fun arg -> not (List.mem arg passed_named_args)) + in + + (* Passed args that the fn does not take *) + let named_args_of_fn_type = + args_from_type + |> List.filter_map (fun arg -> + match arg with + | Noloc.Labelled n | Optional n -> Some n + | Nolabel -> None) + in + let superfluous_args = + passed_named_args + |> List.filter (fun arg -> not (List.mem arg named_args_of_fn_type)) + in + + let is_fallback = + List.length missing_required_args = 0 + && List.length superfluous_args = 0 + && mismatch_in_unlabelled_args = false + in + + if is_fallback then + fprintf ppf "@[@[<2>This function call is incorrect.@]" + else fprintf ppf "@[@[<2>This function call is incorrect:@]"; + + if List.length missing_required_args > 0 then + fprintf ppf "@,- Missing arguments that must be provided: %s" + (missing_required_args + |> List.map (fun v -> "~" ^ v) + |> String.concat ", "); + + if List.length superfluous_args > 0 then + fprintf ppf "@,- Called with arguments it does not take: %s" + (superfluous_args |> String.concat ", "); + + if mismatch_in_unlabelled_args then + fprintf ppf + "@,\ + - It takes @{%s@} unlabelled argument%s, but is called with \ + @{%s@}" + (if args_from_type_unlabelled > sargs_unlabelled then + string_of_int args_from_type_unlabelled + else "just " ^ string_of_int args_from_type_unlabelled) + (if args_from_type_unlabelled = 1 then "" else "s") + (if sargs_unlabelled > args_from_type_unlabelled then + string_of_int sargs_unlabelled + else "just " ^ string_of_int sargs_unlabelled); + + if not is_fallback then fprintf ppf "@,"; + fprintf ppf "@,The function has type:@ %a" type_expr typ; + + (* Print fallback if nothing above matched *) + if is_fallback then + fprintf ppf + "@,\ + @,\ + It is called with @{%d@} argument%s but requires%s \ + @{%d@}." + args + (if args > arity then " just" else "") + (if args = 1 then "" else "s") + arity; + + fprintf ppf "@]" | Field_not_optional (name, typ) -> fprintf ppf "Field @{%s@} is not optional in type %a. Use without ?" name type_expr typ diff --git a/compiler/ml/typecore.mli b/compiler/ml/typecore.mli index 3aa23756d4..c11f557a2e 100644 --- a/compiler/ml/typecore.mli +++ b/compiler/ml/typecore.mli @@ -100,7 +100,8 @@ type error = | Unknown_literal of string * char | Illegal_letrec_pat | Empty_record_literal - | Uncurried_arity_mismatch of type_expr * int * int + | Uncurried_arity_mismatch of + type_expr * int * int * Asttypes.Noloc.arg_label list | Field_not_optional of string * type_expr | Type_params_not_supported of Longident.t | Field_access_on_dict_type diff --git a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected index 40b7bc2359..900a452b3e 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected @@ -6,5 +6,8 @@ 2 │ let makeVariables = makeVar(~f=f => f) 3 │ - This function has type (~f: 'a => 'a, unit) => int - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - It takes 1 unlabelled argument, but is called with just 0 + + The function has type: + (~f: 'a => 'a, unit) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected index 2792426982..ffd8186fe0 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected @@ -6,5 +6,8 @@ 2 │ let makeVariables = makeVar(1, 2, 3) 3 │ - This function has type ('a, unit) => int - It is applied with 3 arguments but it requires 2. \ No newline at end of file + Can't call this function: + - It takes just 2 unlabelled arguments, but is called with 3 + + The function has type: + ('a, unit) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected b/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected index e19cffd36e..ee7fc37fea 100644 --- a/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected +++ b/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected @@ -19,5 +19,5 @@ 4 │ let err = f(1, 2) 5 │ - The function applied to this argument has type ('a, ~def: int=?) => 'b -This argument cannot be applied without label \ No newline at end of file + This function does not take an unlabelled argument at this position. + It has type: ('a, ~def: int=?) => 'b \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected b/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected index 54fcade1ac..031dd0cf49 100644 --- a/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected +++ b/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected @@ -19,6 +19,5 @@ 7 │ let err = r("", ~initialValue=2) 8 │ - The function applied to this argument has type - (string, ~wrongLabelName: int=?) => 'a -This argument cannot be applied with label ~initialValue \ No newline at end of file + This function does not take the argument ~initialValue. + It has type: (string, ~wrongLabelName: int=?) => 'a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected b/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected index 03f0671056..9075e15bcc 100644 --- a/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected @@ -8,5 +8,8 @@ 4 │ } 5 │ - This function has type (int, int) => unit - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function. + The function has type: + (int, int) => unit + + It is called with 1 argument but it requires 2. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_label.res.expected b/tests/build_tests/super_errors/expected/missing_label.res.expected index c25d28bc84..cab877a085 100644 --- a/tests/build_tests/super_errors/expected/missing_label.res.expected +++ b/tests/build_tests/super_errors/expected/missing_label.res.expected @@ -7,5 +7,5 @@ 3 │ let _ = f("") 4 │ - The function applied to this argument has type (~a: string) => string -This argument cannot be applied without label \ No newline at end of file + This function does not take an unlabelled argument at this position. + It has type: (~a: string) => string \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_labels.res.expected b/tests/build_tests/super_errors/expected/missing_labels.res.expected index e4c64c60c3..51be547b60 100644 --- a/tests/build_tests/super_errors/expected/missing_labels.res.expected +++ b/tests/build_tests/super_errors/expected/missing_labels.res.expected @@ -7,6 +7,5 @@ 3 │ let _ = f("", "") 4 │ - The function applied to this argument has type - (~a: string, ~b: string) => string -This argument cannot be applied without label \ No newline at end of file + This function does not take an unlabelled argument at this position. + It has type: (~a: string, ~b: string) => string \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments1.res.expected b/tests/build_tests/super_errors/expected/moreArguments1.res.expected index 4e97918003..f2a1a388a3 100644 --- a/tests/build_tests/super_errors/expected/moreArguments1.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments1.res.expected @@ -6,5 +6,8 @@ 2 │ let y = x(~a=2) + 2 3 │ - This function has type (~a: int, ~b: int) => int - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - Missing required arguments: ~b + + The function has type: + (~a: int, ~b: int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments2.res.expected b/tests/build_tests/super_errors/expected/moreArguments2.res.expected index 90b03e1d46..05a777ab1b 100644 --- a/tests/build_tests/super_errors/expected/moreArguments2.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments2.res.expected @@ -6,5 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function has type (int, int) => int - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - It takes 2 unlabelled arguments, but is called with just 1 + + The function has type: + (int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments3.res.expected b/tests/build_tests/super_errors/expected/moreArguments3.res.expected index 9bbbaca9a3..b7311c62b9 100644 --- a/tests/build_tests/super_errors/expected/moreArguments3.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments3.res.expected @@ -6,5 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function has type (int, int, 'a, 'b) => int - It is applied with 1 argument but it requires 4. \ No newline at end of file + Can't call this function: + - It takes 4 unlabelled arguments, but is called with just 1 + + The function has type: + (int, int, 'a, 'b) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments4.res.expected b/tests/build_tests/super_errors/expected/moreArguments4.res.expected index 17fa54bee7..1eb83e611a 100644 --- a/tests/build_tests/super_errors/expected/moreArguments4.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments4.res.expected @@ -6,5 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function has type (int, ~b: int, ~c: 'a, ~d: 'b) => int - It is applied with 1 argument but it requires 4. \ No newline at end of file + Can't call this function: + - Missing required arguments: ~d, ~c, ~b + + The function has type: + (int, ~b: int, ~c: 'a, ~d: 'b) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments5.res.expected b/tests/build_tests/super_errors/expected/moreArguments5.res.expected index e0ec49e0d5..c6807e9f33 100644 --- a/tests/build_tests/super_errors/expected/moreArguments5.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments5.res.expected @@ -7,5 +7,8 @@ 5 │ let y = x(2).Sub.a 6 │ - This function has type (int, 'a, 'b, 'c) => Sub.a - It is applied with 1 argument but it requires 4. \ No newline at end of file + Can't call this function: + - It takes 4 unlabelled arguments, but is called with just 1 + + The function has type: + (int, 'a, 'b, 'c) => Sub.a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected b/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected index 3d1381d80f..01076cbd58 100644 --- a/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected +++ b/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected @@ -6,5 +6,5 @@ 2 │ let _ = nonfun(3) 3 │ - This expression has type int - It is not a function. \ No newline at end of file + This can't be called, it's not a function. + It has type: int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected index 67fc28c1ab..d46651219b 100644 --- a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected +++ b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected @@ -6,5 +6,8 @@ 2 │ let x = f(42) 3 │ - This function has type (~a: int=?, int, int) => int - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - It takes 2 unlabelled arguments, but is called with just 1 + + The function has type: + (~a: int=?, int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/partial_app.res.expected b/tests/build_tests/super_errors/expected/partial_app.res.expected index 7b57e9dee5..8f649996b4 100644 --- a/tests/build_tests/super_errors/expected/partial_app.res.expected +++ b/tests/build_tests/super_errors/expected/partial_app.res.expected @@ -7,5 +7,8 @@ 5 │ f(1, 2) 6 │ - This function has type (int, int, int) => int - It is applied with 2 arguments but it requires 3. \ No newline at end of file + Can't call this function: + - It takes 3 unlabelled arguments, but is called with just 2 + + The function has type: + (int, int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/primitives3.res.expected b/tests/build_tests/super_errors/expected/primitives3.res.expected index 55bc7744e7..9b5b83a444 100644 --- a/tests/build_tests/super_errors/expected/primitives3.res.expected +++ b/tests/build_tests/super_errors/expected/primitives3.res.expected @@ -7,5 +7,8 @@ 3 │ x(2, 4) 4 │ - This function has type int => int - It is applied with 2 arguments but it requires 1. \ No newline at end of file + Can't call this function: + - It takes just 1 unlabelled argument, but is called with 2 + + The function has type: + int => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/primitives4.res.expected b/tests/build_tests/super_errors/expected/primitives4.res.expected index 09773d5295..3737957db5 100644 --- a/tests/build_tests/super_errors/expected/primitives4.res.expected +++ b/tests/build_tests/super_errors/expected/primitives4.res.expected @@ -7,5 +7,5 @@ 3 │ x(10) 4 │ - This expression has type int - It is not a function. \ No newline at end of file + This can't be called, it's not a function. + It has type: int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/recursive_type.res.expected b/tests/build_tests/super_errors/expected/recursive_type.res.expected index ebb72770eb..8cf2645dc6 100644 --- a/tests/build_tests/super_errors/expected/recursive_type.res.expected +++ b/tests/build_tests/super_errors/expected/recursive_type.res.expected @@ -8,6 +8,8 @@ 35 │ assert(false) 36 │ } - This function has type - ((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - It takes 2 unlabelled arguments, but is called with just 1 + + The function has type: + ((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected index 2c3bd273d4..12e9ebd1c1 100644 --- a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected +++ b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected @@ -7,6 +7,5 @@ 6 │ let d = foo(~y=3) 7 │ - The function applied to this argument has type - (~x: int) => (~y: int) => int -This argument cannot be applied with label ~y \ No newline at end of file + This function does not take the argument ~y. + It has type: (~x: int) => (~y: int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warnings1.res.expected b/tests/build_tests/super_errors/expected/warnings1.res.expected index 4b94a89f5a..5f2d32cfc7 100644 --- a/tests/build_tests/super_errors/expected/warnings1.res.expected +++ b/tests/build_tests/super_errors/expected/warnings1.res.expected @@ -8,5 +8,8 @@ 4 │ 10 5 │ } - This function has type (int, int) => int - It is applied with 1 argument but it requires 2. \ No newline at end of file + Can't call this function: + - It takes 2 unlabelled arguments, but is called with just 1 + + The function has type: + (int, int) => int \ No newline at end of file From de8784851db249ae26825913b66cb00daaa22dc7 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 21 May 2025 15:10:21 +0200 Subject: [PATCH 2/3] update test output --- .../super_errors/expected/arity_mismatch.res.expected | 4 ++-- .../super_errors/expected/arity_mismatch2.res.expected | 4 ++-- .../super_errors/expected/method_arity_mismatch.res.expected | 4 ++-- .../super_errors/expected/moreArguments1.res.expected | 4 ++-- .../super_errors/expected/moreArguments2.res.expected | 4 ++-- .../super_errors/expected/moreArguments3.res.expected | 4 ++-- .../super_errors/expected/moreArguments4.res.expected | 4 ++-- .../super_errors/expected/moreArguments5.res.expected | 4 ++-- .../super_errors/expected/opt_args_arity.res.expected | 4 ++-- .../super_errors/expected/partial_app.res.expected | 4 ++-- .../super_errors/expected/primitives3.res.expected | 4 ++-- .../super_errors/expected/recursive_type.res.expected | 4 ++-- .../build_tests/super_errors/expected/warnings1.res.expected | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected index 900a452b3e..10d75ec5c4 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected @@ -6,8 +6,8 @@ 2 │ let makeVariables = makeVar(~f=f => f) 3 │ - Can't call this function: - - It takes 1 unlabelled argument, but is called with just 0 + This function call is incorrect: + - It takes 1 unlabelled argument, but is called with just 0 The function has type: (~f: 'a => 'a, unit) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected index ffd8186fe0..48f3d8fa95 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected @@ -6,8 +6,8 @@ 2 │ let makeVariables = makeVar(1, 2, 3) 3 │ - Can't call this function: - - It takes just 2 unlabelled arguments, but is called with 3 + This function call is incorrect: + - It takes just 2 unlabelled arguments, but is called with 3 The function has type: ('a, unit) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected b/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected index 9075e15bcc..1cfc6c2e9a 100644 --- a/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/method_arity_mismatch.res.expected @@ -8,8 +8,8 @@ 4 │ } 5 │ - Can't call this function. + This function call is incorrect. The function has type: (int, int) => unit - It is called with 1 argument but it requires 2. \ No newline at end of file + It is called with 1 argument but requires 2. \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments1.res.expected b/tests/build_tests/super_errors/expected/moreArguments1.res.expected index f2a1a388a3..be9b4d28d8 100644 --- a/tests/build_tests/super_errors/expected/moreArguments1.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments1.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(~a=2) + 2 3 │ - Can't call this function: - - Missing required arguments: ~b + This function call is incorrect: + - Missing arguments that must be provided: ~b The function has type: (~a: int, ~b: int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments2.res.expected b/tests/build_tests/super_errors/expected/moreArguments2.res.expected index 05a777ab1b..d7ae2a464d 100644 --- a/tests/build_tests/super_errors/expected/moreArguments2.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments2.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - Can't call this function: - - It takes 2 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 2 unlabelled arguments, but is called with just 1 The function has type: (int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments3.res.expected b/tests/build_tests/super_errors/expected/moreArguments3.res.expected index b7311c62b9..8dce4bfcab 100644 --- a/tests/build_tests/super_errors/expected/moreArguments3.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments3.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - Can't call this function: - - It takes 4 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 4 unlabelled arguments, but is called with just 1 The function has type: (int, int, 'a, 'b) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments4.res.expected b/tests/build_tests/super_errors/expected/moreArguments4.res.expected index 1eb83e611a..827d4ea96b 100644 --- a/tests/build_tests/super_errors/expected/moreArguments4.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments4.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - Can't call this function: - - Missing required arguments: ~d, ~c, ~b + This function call is incorrect: + - Missing arguments that must be provided: ~d, ~c, ~b The function has type: (int, ~b: int, ~c: 'a, ~d: 'b) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments5.res.expected b/tests/build_tests/super_errors/expected/moreArguments5.res.expected index c6807e9f33..6584abbfbc 100644 --- a/tests/build_tests/super_errors/expected/moreArguments5.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments5.res.expected @@ -7,8 +7,8 @@ 5 │ let y = x(2).Sub.a 6 │ - Can't call this function: - - It takes 4 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 4 unlabelled arguments, but is called with just 1 The function has type: (int, 'a, 'b, 'c) => Sub.a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected index d46651219b..0c64571b0e 100644 --- a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected +++ b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected @@ -6,8 +6,8 @@ 2 │ let x = f(42) 3 │ - Can't call this function: - - It takes 2 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 2 unlabelled arguments, but is called with just 1 The function has type: (~a: int=?, int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/partial_app.res.expected b/tests/build_tests/super_errors/expected/partial_app.res.expected index 8f649996b4..c0c3f82abd 100644 --- a/tests/build_tests/super_errors/expected/partial_app.res.expected +++ b/tests/build_tests/super_errors/expected/partial_app.res.expected @@ -7,8 +7,8 @@ 5 │ f(1, 2) 6 │ - Can't call this function: - - It takes 3 unlabelled arguments, but is called with just 2 + This function call is incorrect: + - It takes 3 unlabelled arguments, but is called with just 2 The function has type: (int, int, int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/primitives3.res.expected b/tests/build_tests/super_errors/expected/primitives3.res.expected index 9b5b83a444..f8cd6d78d8 100644 --- a/tests/build_tests/super_errors/expected/primitives3.res.expected +++ b/tests/build_tests/super_errors/expected/primitives3.res.expected @@ -7,8 +7,8 @@ 3 │ x(2, 4) 4 │ - Can't call this function: - - It takes just 1 unlabelled argument, but is called with 2 + This function call is incorrect: + - It takes just 1 unlabelled argument, but is called with 2 The function has type: int => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/recursive_type.res.expected b/tests/build_tests/super_errors/expected/recursive_type.res.expected index 8cf2645dc6..ba7c7ac50d 100644 --- a/tests/build_tests/super_errors/expected/recursive_type.res.expected +++ b/tests/build_tests/super_errors/expected/recursive_type.res.expected @@ -8,8 +8,8 @@ 35 │ assert(false) 36 │ } - Can't call this function: - - It takes 2 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 2 unlabelled arguments, but is called with just 1 The function has type: ((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warnings1.res.expected b/tests/build_tests/super_errors/expected/warnings1.res.expected index 5f2d32cfc7..b0f2a4af54 100644 --- a/tests/build_tests/super_errors/expected/warnings1.res.expected +++ b/tests/build_tests/super_errors/expected/warnings1.res.expected @@ -8,8 +8,8 @@ 4 │ 10 5 │ } - Can't call this function: - - It takes 2 unlabelled arguments, but is called with just 1 + This function call is incorrect: + - It takes 2 unlabelled arguments, but is called with just 1 The function has type: (int, int) => int \ No newline at end of file From ff18cece96b922fdfa0d0af598863712b4b42211 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Wed, 21 May 2025 17:46:40 +0200 Subject: [PATCH 3/3] adjust messages --- compiler/ml/typecore.ml | 45 ++++++++++--------- .../expected/arity_mismatch.res.expected | 8 ++-- .../expected/arity_mismatch2.res.expected | 8 ++-- .../expected/arity_mismatch4.res.expected | 13 ++++++ .../expected/fun_return_poly1.res.expected | 4 +- .../expected/fun_return_poly2.res.expected | 2 +- .../expected/missing_label.res.expected | 4 +- .../expected/missing_labels.res.expected | 4 +- .../expected/moreArguments1.res.expected | 8 ++-- .../expected/moreArguments2.res.expected | 8 ++-- .../expected/moreArguments3.res.expected | 8 ++-- .../expected/moreArguments4.res.expected | 8 ++-- .../expected/moreArguments5.res.expected | 8 ++-- .../non_function_uncurried_apply.res.expected | 2 +- .../expected/opt_args_arity.res.expected | 8 ++-- .../expected/partial_app.res.expected | 8 ++-- .../expected/primitives3.res.expected | 8 ++-- .../expected/primitives4.res.expected | 2 +- .../expected/recursive_type.res.expected | 8 ++-- .../uncurried_wrong_label.res.expected | 2 +- .../expected/warnings1.res.expected | 8 ++-- .../super_errors/fixtures/arity_mismatch4.res | 2 + 22 files changed, 98 insertions(+), 78 deletions(-) create mode 100644 tests/build_tests/super_errors/expected/arity_mismatch4.res.expected create mode 100644 tests/build_tests/super_errors/fixtures/arity_mismatch4.res diff --git a/compiler/ml/typecore.ml b/compiler/ml/typecore.ml index 69e9b2309c..d298390708 100644 --- a/compiler/ml/typecore.ml +++ b/compiler/ml/typecore.ml @@ -4259,15 +4259,18 @@ let report_error env ppf error = | _ -> fprintf ppf "@[@[<2>This can't be called, it's not a function.@]@,\ - It has type: %a@]" + The function has type: %a@]" type_expr typ) | Apply_wrong_label (l, ty) -> - let print_label ppf = function - | Noloc.Nolabel -> fprintf ppf "an unlabelled argument at this position" - | l -> fprintf ppf "the argument @{%s@}" (prefixed_label_name l) + let print_message ppf = function + | Noloc.Nolabel -> + fprintf ppf "The argument at this position should be labelled." + | l -> + fprintf ppf "This function does not take the argument @{%s@}." + (prefixed_label_name l) in - fprintf ppf "@[@[<2>This function does not take %a.@]@,It has type: %a@]" - print_label l type_expr ty + fprintf ppf "@[@[<2>%a@]@,This function has type: %a@]" print_message l + type_expr ty | Label_multiply_defined {label; jsx_component_info = Some jsx_component_info} -> fprintf ppf @@ -4482,9 +4485,10 @@ let report_error env ppf error = && mismatch_in_unlabelled_args = false in - if is_fallback then - fprintf ppf "@[@[<2>This function call is incorrect.@]" - else fprintf ppf "@[@[<2>This function call is incorrect:@]"; + fprintf ppf "@[@[<2>This function call is incorrect.@]"; + fprintf ppf "@,The function has type:@ %a" type_expr typ; + + if not is_fallback then fprintf ppf "@,"; if List.length missing_required_args > 0 then fprintf ppf "@,- Missing arguments that must be provided: %s" @@ -4496,21 +4500,22 @@ let report_error env ppf error = fprintf ppf "@,- Called with arguments it does not take: %s" (superfluous_args |> String.concat ", "); + let unlabelled_msg a b pos = + match (a, pos) with + | 0, `left -> "no" + | 0, `right -> "none" + | _ when a > b -> string_of_int a + | _ -> "just " ^ string_of_int a + in + if mismatch_in_unlabelled_args then fprintf ppf "@,\ - - It takes @{%s@} unlabelled argument%s, but is called with \ - @{%s@}" - (if args_from_type_unlabelled > sargs_unlabelled then - string_of_int args_from_type_unlabelled - else "just " ^ string_of_int args_from_type_unlabelled) + - The function takes @{%s@} unlabelled argument%s, but is \ + called with @{%s@}" + (unlabelled_msg args_from_type_unlabelled sargs_unlabelled `left) (if args_from_type_unlabelled = 1 then "" else "s") - (if sargs_unlabelled > args_from_type_unlabelled then - string_of_int sargs_unlabelled - else "just " ^ string_of_int sargs_unlabelled); - - if not is_fallback then fprintf ppf "@,"; - fprintf ppf "@,The function has type:@ %a" type_expr typ; + (unlabelled_msg sargs_unlabelled args_from_type_unlabelled `right); (* Print fallback if nothing above matched *) if is_fallback then diff --git a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected index 10d75ec5c4..5b58aeb36b 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch.res.expected @@ -6,8 +6,8 @@ 2 │ let makeVariables = makeVar(~f=f => f) 3 │ - This function call is incorrect: - - It takes 1 unlabelled argument, but is called with just 0 - + This function call is incorrect. The function has type: - (~f: 'a => 'a, unit) => int \ No newline at end of file + (~f: 'a => 'a, unit) => int + + - The function takes 1 unlabelled argument, but is called with none \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected index 48f3d8fa95..df93ef0e60 100644 --- a/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected +++ b/tests/build_tests/super_errors/expected/arity_mismatch2.res.expected @@ -6,8 +6,8 @@ 2 │ let makeVariables = makeVar(1, 2, 3) 3 │ - This function call is incorrect: - - It takes just 2 unlabelled arguments, but is called with 3 - + This function call is incorrect. The function has type: - ('a, unit) => int \ No newline at end of file + ('a, unit) => int + + - The function takes just 2 unlabelled arguments, but is called with 3 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/arity_mismatch4.res.expected b/tests/build_tests/super_errors/expected/arity_mismatch4.res.expected new file mode 100644 index 0000000000..323e047b6c --- /dev/null +++ b/tests/build_tests/super_errors/expected/arity_mismatch4.res.expected @@ -0,0 +1,13 @@ + + We've found a bug for you! + /.../fixtures/arity_mismatch4.res:2:21-27 + + 1 │ let makeVar = (~f) => 34 + 2 │ let makeVariables = makeVar(1, ~f=f => f) + 3 │ + + This function call is incorrect. + The function has type: + (~f: 'a) => int + + - The function takes no unlabelled arguments, but is called with 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected b/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected index ee7fc37fea..8e030be3c4 100644 --- a/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected +++ b/tests/build_tests/super_errors/expected/fun_return_poly1.res.expected @@ -19,5 +19,5 @@ 4 │ let err = f(1, 2) 5 │ - This function does not take an unlabelled argument at this position. - It has type: ('a, ~def: int=?) => 'b \ No newline at end of file + The argument at this position should be labelled. + This function has type: ('a, ~def: int=?) => 'b \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected b/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected index 031dd0cf49..acddb916ba 100644 --- a/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected +++ b/tests/build_tests/super_errors/expected/fun_return_poly2.res.expected @@ -20,4 +20,4 @@ 8 │ This function does not take the argument ~initialValue. - It has type: (string, ~wrongLabelName: int=?) => 'a \ No newline at end of file + This function has type: (string, ~wrongLabelName: int=?) => 'a \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_label.res.expected b/tests/build_tests/super_errors/expected/missing_label.res.expected index cab877a085..a228ddd495 100644 --- a/tests/build_tests/super_errors/expected/missing_label.res.expected +++ b/tests/build_tests/super_errors/expected/missing_label.res.expected @@ -7,5 +7,5 @@ 3 │ let _ = f("") 4 │ - This function does not take an unlabelled argument at this position. - It has type: (~a: string) => string \ No newline at end of file + The argument at this position should be labelled. + This function has type: (~a: string) => string \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/missing_labels.res.expected b/tests/build_tests/super_errors/expected/missing_labels.res.expected index 51be547b60..9f06e19ec6 100644 --- a/tests/build_tests/super_errors/expected/missing_labels.res.expected +++ b/tests/build_tests/super_errors/expected/missing_labels.res.expected @@ -7,5 +7,5 @@ 3 │ let _ = f("", "") 4 │ - This function does not take an unlabelled argument at this position. - It has type: (~a: string, ~b: string) => string \ No newline at end of file + The argument at this position should be labelled. + This function has type: (~a: string, ~b: string) => string \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments1.res.expected b/tests/build_tests/super_errors/expected/moreArguments1.res.expected index be9b4d28d8..34bf4baf0e 100644 --- a/tests/build_tests/super_errors/expected/moreArguments1.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments1.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(~a=2) + 2 3 │ - This function call is incorrect: - - Missing arguments that must be provided: ~b - + This function call is incorrect. The function has type: - (~a: int, ~b: int) => int \ No newline at end of file + (~a: int, ~b: int) => int + + - Missing arguments that must be provided: ~b \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments2.res.expected b/tests/build_tests/super_errors/expected/moreArguments2.res.expected index d7ae2a464d..09bc889be5 100644 --- a/tests/build_tests/super_errors/expected/moreArguments2.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments2.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function call is incorrect: - - It takes 2 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - (int, int) => int \ No newline at end of file + (int, int) => int + + - The function takes 2 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments3.res.expected b/tests/build_tests/super_errors/expected/moreArguments3.res.expected index 8dce4bfcab..937c72d1fb 100644 --- a/tests/build_tests/super_errors/expected/moreArguments3.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments3.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function call is incorrect: - - It takes 4 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - (int, int, 'a, 'b) => int \ No newline at end of file + (int, int, 'a, 'b) => int + + - The function takes 4 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments4.res.expected b/tests/build_tests/super_errors/expected/moreArguments4.res.expected index 827d4ea96b..f7bf2d1769 100644 --- a/tests/build_tests/super_errors/expected/moreArguments4.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments4.res.expected @@ -6,8 +6,8 @@ 2 │ let y = x(2) + 2 3 │ - This function call is incorrect: - - Missing arguments that must be provided: ~d, ~c, ~b - + This function call is incorrect. The function has type: - (int, ~b: int, ~c: 'a, ~d: 'b) => int \ No newline at end of file + (int, ~b: int, ~c: 'a, ~d: 'b) => int + + - Missing arguments that must be provided: ~d, ~c, ~b \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/moreArguments5.res.expected b/tests/build_tests/super_errors/expected/moreArguments5.res.expected index 6584abbfbc..16c7f7e219 100644 --- a/tests/build_tests/super_errors/expected/moreArguments5.res.expected +++ b/tests/build_tests/super_errors/expected/moreArguments5.res.expected @@ -7,8 +7,8 @@ 5 │ let y = x(2).Sub.a 6 │ - This function call is incorrect: - - It takes 4 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - (int, 'a, 'b, 'c) => Sub.a \ No newline at end of file + (int, 'a, 'b, 'c) => Sub.a + + - The function takes 4 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected b/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected index 01076cbd58..615a49939c 100644 --- a/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected +++ b/tests/build_tests/super_errors/expected/non_function_uncurried_apply.res.expected @@ -7,4 +7,4 @@ 3 │ This can't be called, it's not a function. - It has type: int \ No newline at end of file + The function has type: int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected index 0c64571b0e..5994474455 100644 --- a/tests/build_tests/super_errors/expected/opt_args_arity.res.expected +++ b/tests/build_tests/super_errors/expected/opt_args_arity.res.expected @@ -6,8 +6,8 @@ 2 │ let x = f(42) 3 │ - This function call is incorrect: - - It takes 2 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - (~a: int=?, int, int) => int \ No newline at end of file + (~a: int=?, int, int) => int + + - The function takes 2 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/partial_app.res.expected b/tests/build_tests/super_errors/expected/partial_app.res.expected index c0c3f82abd..aae37ac46b 100644 --- a/tests/build_tests/super_errors/expected/partial_app.res.expected +++ b/tests/build_tests/super_errors/expected/partial_app.res.expected @@ -7,8 +7,8 @@ 5 │ f(1, 2) 6 │ - This function call is incorrect: - - It takes 3 unlabelled arguments, but is called with just 2 - + This function call is incorrect. The function has type: - (int, int, int) => int \ No newline at end of file + (int, int, int) => int + + - The function takes 3 unlabelled arguments, but is called with just 2 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/primitives3.res.expected b/tests/build_tests/super_errors/expected/primitives3.res.expected index f8cd6d78d8..ea47a50aad 100644 --- a/tests/build_tests/super_errors/expected/primitives3.res.expected +++ b/tests/build_tests/super_errors/expected/primitives3.res.expected @@ -7,8 +7,8 @@ 3 │ x(2, 4) 4 │ - This function call is incorrect: - - It takes just 1 unlabelled argument, but is called with 2 - + This function call is incorrect. The function has type: - int => int \ No newline at end of file + int => int + + - The function takes just 1 unlabelled argument, but is called with 2 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/primitives4.res.expected b/tests/build_tests/super_errors/expected/primitives4.res.expected index 3737957db5..9f06a57354 100644 --- a/tests/build_tests/super_errors/expected/primitives4.res.expected +++ b/tests/build_tests/super_errors/expected/primitives4.res.expected @@ -8,4 +8,4 @@ 4 │ This can't be called, it's not a function. - It has type: int \ No newline at end of file + The function has type: int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/recursive_type.res.expected b/tests/build_tests/super_errors/expected/recursive_type.res.expected index ba7c7ac50d..3f8d203968 100644 --- a/tests/build_tests/super_errors/expected/recursive_type.res.expected +++ b/tests/build_tests/super_errors/expected/recursive_type.res.expected @@ -8,8 +8,8 @@ 35 │ assert(false) 36 │ } - This function call is incorrect: - - It takes 2 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - ((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c \ No newline at end of file + ((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c + + - The function takes 2 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected index 12e9ebd1c1..ab526fe3a7 100644 --- a/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected +++ b/tests/build_tests/super_errors/expected/uncurried_wrong_label.res.expected @@ -8,4 +8,4 @@ 7 │ This function does not take the argument ~y. - It has type: (~x: int) => (~y: int) => int \ No newline at end of file + This function has type: (~x: int) => (~y: int) => int \ No newline at end of file diff --git a/tests/build_tests/super_errors/expected/warnings1.res.expected b/tests/build_tests/super_errors/expected/warnings1.res.expected index b0f2a4af54..024ddebc3f 100644 --- a/tests/build_tests/super_errors/expected/warnings1.res.expected +++ b/tests/build_tests/super_errors/expected/warnings1.res.expected @@ -8,8 +8,8 @@ 4 │ 10 5 │ } - This function call is incorrect: - - It takes 2 unlabelled arguments, but is called with just 1 - + This function call is incorrect. The function has type: - (int, int) => int \ No newline at end of file + (int, int) => int + + - The function takes 2 unlabelled arguments, but is called with just 1 \ No newline at end of file diff --git a/tests/build_tests/super_errors/fixtures/arity_mismatch4.res b/tests/build_tests/super_errors/fixtures/arity_mismatch4.res new file mode 100644 index 0000000000..f091c15e19 --- /dev/null +++ b/tests/build_tests/super_errors/fixtures/arity_mismatch4.res @@ -0,0 +1,2 @@ +let makeVar = (~f) => 34 +let makeVariables = makeVar(1, ~f=f => f)