Skip to content

Commit 54f118d

Browse files
authored
Hint about partial application in error where required labels are missing (#7807)
* hint about partial application * examplify partial application * changelog
1 parent f8c108f commit 54f118d

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
- Make parser less strict around leading attributes. https://github.com/rescript-lang/rescript/pull/7787
3434
- Dedicated error message for ternary type mismatch. https://github.com/rescript-lang/rescript/pull/7804
3535
- Dedicated error message for passing a braced ident to something expected to be a record. https://github.com/rescript-lang/rescript/pull/7806
36+
- Hint about partial application when missing required argument in function call. https://github.com/rescript-lang/rescript/pull/7807
3637

3738
#### :house: Internal
3839

compiler/ml/typecore.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4667,12 +4667,18 @@ let report_error env loc ppf error =
46674667
46684668
if not is_fallback then fprintf ppf "@,";
46694669
4670-
if List.length missing_required_args > 0 then
4670+
if List.length missing_required_args > 0 then (
46714671
fprintf ppf "@,- Missing arguments that must be provided: %s"
46724672
(missing_required_args
46734673
|> List.map (fun v -> "~" ^ v)
46744674
|> String.concat ", ");
46754675
4676+
fprintf ppf
4677+
"@,\
4678+
- Hint: Did you want to partially apply the function? You can do that \
4679+
by putting `...` just before the closing parens of the function call. \
4680+
Example: @{<info>yourFn(~arg1=someVar, ...)@}");
4681+
46764682
if List.length superfluous_args > 0 then
46774683
fprintf ppf "@,- Called with arguments it does not take: %s"
46784684
(superfluous_args |> String.concat ", ");

tests/build_tests/super_errors/expected/moreArguments1.res.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
The function has type:
1111
(~a: int, ~b: int) => int
1212

13-
- Missing arguments that must be provided: ~b
13+
- Missing arguments that must be provided: ~b
14+
- 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, ...)

tests/build_tests/super_errors/expected/moreArguments4.res.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010
The function has type:
1111
(int, ~b: int, ~c: 'a, ~d: 'b) => int
1212

13-
- Missing arguments that must be provided: ~d, ~c, ~b
13+
- Missing arguments that must be provided: ~d, ~c, ~b
14+
- 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, ...)

0 commit comments

Comments
 (0)