Skip to content

Commit 70900aa

Browse files
authored
Improve error messages for function arity errors (rescript-lang#6990)
* Improve some error texts ("uncurried function" -> "function") * CHANGELOG
1 parent c4f5b1b commit 70900aa

14 files changed

+14
-13
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
- Fix `Js.Types.JSBigInt` payload to use native `bigint` type. https://github.com/rescript-lang/rescript-compiler/pull/6911
121121
- Deprecate `%external` extension, which has never been officially introduced. https://github.com/rescript-lang/rescript-compiler/pull/6906
122122
- Deprecate `xxxU` functions in Belt. https://github.com/rescript-lang/rescript-compiler/pull/6941
123+
- Improve error messages for function arity errors. https://github.com/rescript-lang/rescript-compiler/pull/6990
123124

124125
# 11.1.3
125126

jscomp/build_tests/super_errors/expected/arity_mismatch.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let makeVariables = makeVar(.~f=f => f)
77
3 │
88

9-
This uncurried function has type (~f: 'a => 'a, unit) => int
9+
This function has type (~f: 'a => 'a, unit) => int
1010
It is applied with 1 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/arity_mismatch2.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let makeVariables = makeVar(. 1, 2, 3)
77
3 │
88

9-
This uncurried function has type ('a, unit) => int
9+
This function has type ('a, unit) => int
1010
It is applied with 3 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/method_arity_mismatch.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
4 │ }
99
5 │
1010

11-
This uncurried function has type (int, int) => unit
11+
This function has type (int, int) => unit
1212
It is applied with 1 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/moreArguments1.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let y = x(~a=2) + 2
77
3 │
88

9-
This uncurried function has type (~a: int, ~b: int) => int
9+
This function has type (~a: int, ~b: int) => int
1010
It is applied with 1 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/moreArguments2.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let y = x(2) + 2
77
3 │
88

9-
This uncurried function has type (int, int) => int
9+
This function has type (int, int) => int
1010
It is applied with 1 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/moreArguments3.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let y = x(2) + 2
77
3 │
88

9-
This uncurried function has type (int, int, 'a, 'b) => int
9+
This function has type (int, int, 'a, 'b) => int
1010
It is applied with 1 arguments but it requires 4.

jscomp/build_tests/super_errors/expected/moreArguments4.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
2 │ let y = x(2) + 2
77
3 │
88

9-
This uncurried function has type (int, ~b: int, ~c: 'a, ~d: 'b) => int
9+
This function has type (int, ~b: int, ~c: 'a, ~d: 'b) => int
1010
It is applied with 1 arguments but it requires 4.

jscomp/build_tests/super_errors/expected/moreArguments5.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
5 │ let y = x(2).Sub.a
88
6 │
99

10-
This uncurried function has type (int, 'a, 'b, 'c) => Sub.a
10+
This function has type (int, 'a, 'b, 'c) => Sub.a
1111
It is applied with 1 arguments but it requires 4.

jscomp/build_tests/super_errors/expected/partial_app.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
5 │ f(1, 2)
88
6 │
99

10-
This uncurried function has type (int, int, int) => int
10+
This function has type (int, int, int) => int
1111
It is applied with 2 arguments but it requires 3.

jscomp/build_tests/super_errors/expected/primitives3.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
3 │ x(2, 4)
88
4 │
99

10-
This uncurried function has type int => int
10+
This function has type int => int
1111
It is applied with 2 arguments but it requires 1.

jscomp/build_tests/super_errors/expected/recursive_type.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
36 │ assert(false)
99
37 │ }
1010

11-
This uncurried function has type
11+
This function has type
1212
((option<'a>, ([> #List(list<'b>)] as 'b)) => 'c, 'd) => 'c
1313
It is applied with 1 arguments but it requires 2.

jscomp/build_tests/super_errors/expected/warnings1.res.expected

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
4 │ 10
99
5 │ }
1010

11-
This uncurried function has type (int, int) => int
11+
This function has type (int, int) => int
1212
It is applied with 1 arguments but it requires 2.

jscomp/ml/typecore.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4011,7 +4011,7 @@ let report_error env ppf = function
40114011
| Empty_record_literal ->
40124012
fprintf ppf "Empty record literal {} should be type annotated or used in a record context."
40134013
| Uncurried_arity_mismatch (typ, arity, args) ->
4014-
fprintf ppf "@[<v>@[<2>This uncurried function has type@ %a@]"
4014+
fprintf ppf "@[<v>@[<2>This function has type@ %a@]"
40154015
type_expr typ;
40164016
fprintf ppf "@ @[It is applied with @{<error>%d@} argument%s but it requires @{<info>%d@}.@]@]"
40174017
args (if args = 0 then "" else "s") arity

0 commit comments

Comments
 (0)