@@ -119,6 +119,12 @@ let print_expr_type_clash env trace ppf = begin
119
119
show_extra_help ppf env trace;
120
120
end
121
121
122
+ let reportArityMismatch ~arityA ~arityB ppf =
123
+ fprintf ppf " This function expected @{<info>%s@} %s, but got @{<error>%s@}"
124
+ arityA
125
+ (if arityA = " 1" then " argument" else " arguments" )
126
+ arityB
127
+
122
128
let reportJsFnArityMismatch ~arityA ~arityB ppf =
123
129
let extractArity s =
124
130
if Ext_string. starts_with s " arity" then
@@ -128,12 +134,9 @@ let reportJsFnArityMismatch ~arityA ~arityB ppf =
128
134
else
129
135
raise (Invalid_argument " Unrecognized arity type name." )
130
136
in
131
- let firstNumber = extractArity arityA in
132
- fprintf ppf " This function expected @{<info>%s@} %s, but got @{<error>%s@}"
133
- firstNumber
134
- (if firstNumber = " 1" then " argument" else " arguments" )
135
- (extractArity arityB)
136
-
137
+ let arityA = extractArity arityA in
138
+ let arityB = extractArity arityB in
139
+ reportArityMismatch ~arity A ~arity B ppf
137
140
138
141
(* Pasted from typecore.ml. Needed for some cases in report_error below *)
139
142
(* Records *)
@@ -177,13 +180,24 @@ let report_error env ppf = function
177
180
| Expr_type_clash (
178
181
(_, {desc = Tarrow _}) ::
179
182
(_, {desc = Tconstr (Pdot (Pdot (Pident {name = " Js" }," Fn" ,_),_,_),_,_)}) :: _
180
- ) ->
183
+ )
184
+ | Expr_type_clash (
185
+ (_, {desc = Tarrow _}) ::
186
+ (_, {desc = Tconstr (Pident {name = " uncurried$" },_,_)}) :: _
187
+ ) ->
181
188
fprintf ppf " This function is a curried function where an uncurried function is expected"
182
189
| Expr_type_clash (
183
190
(_, {desc = Tconstr (Pdot (Pdot (Pident {name = " Js" }," Fn" ,_),arityA,_),_,_)}) ::
184
191
(_, {desc = Tconstr (Pdot (Pdot (Pident {name = " Js" }," Fn" ,_),arityB,_),_,_)}) :: _
185
192
) when arityA <> arityB ->
186
193
reportJsFnArityMismatch ~arity A ~arity B ppf
194
+ | Expr_type_clash (
195
+ (_, {desc = Tconstr (Pident {name = " uncurried$" },[_; tA],_)}) ::
196
+ (_, {desc = Tconstr (Pident {name = " uncurried$" },[_; tB],_)}) :: _
197
+ ) when Ast_uncurried. type_to_arity tA <> Ast_uncurried. type_to_arity tB ->
198
+ let arityA = Ast_uncurried. type_to_arity tA |> string_of_int in
199
+ let arityB = Ast_uncurried. type_to_arity tB |> string_of_int in
200
+ reportArityMismatch ~arity A ~arity B ppf
187
201
| Expr_type_clash (
188
202
(_, {desc = Tconstr (Pdot (Pdot (Pident {name = " Js_OO" }," Meth" ,_),a,_),_,_)}) ::
189
203
(_, {desc = Tconstr (Pdot (Pdot (Pident {name = " Js_OO" }," Meth" ,_),b,_),_,_)}) :: _
0 commit comments