Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Make parser less strict around leading attributes. https://github.com/rescript-lang/rescript/pull/7787
- Dedicated error message for ternary type mismatch. https://github.com/rescript-lang/rescript/pull/7804
- Dedicated error message for passing a braced ident to something expected to be a record. https://github.com/rescript-lang/rescript/pull/7806
- Hint about partial application when missing required argument in function call. https://github.com/rescript-lang/rescript/pull/7807

#### :house: Internal

Expand Down
8 changes: 7 additions & 1 deletion compiler/ml/typecore.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4667,12 +4667,18 @@ let report_error env loc ppf error =

if not is_fallback then fprintf ppf "@,";

if List.length missing_required_args > 0 then
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 ", ");

fprintf ppf
"@,\
- Hint: Did you want to partially apply the function? You can do that \
by putting `...` just before the closing parens of the function call. \
Example: @{<info>yourFn(~arg1=someVar, ...)@}");

if List.length superfluous_args > 0 then
fprintf ppf "@,- Called with arguments it does not take: %s"
(superfluous_args |> String.concat ", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
The function has type:
(~a: int, ~b: int) => int

- Missing arguments that must be provided: ~b
- Missing arguments that must be provided: ~b
- Hint: Did you want to partially apply the function? You can do that by putting `...` just before the closing parens of the function call. Example: yourFn(~arg1=someVar, ...)
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
The function has type:
(int, ~b: int, ~c: 'a, ~d: 'b) => int

- Missing arguments that must be provided: ~d, ~c, ~b
- Missing arguments that must be provided: ~d, ~c, ~b
- Hint: Did you want to partially apply the function? You can do that by putting `...` just before the closing parens of the function call. Example: yourFn(~arg1=someVar, ...)
Loading