@@ -2011,7 +2011,7 @@ let close_let_rec acc env ~function_declarations
2011
2011
named ~body
2012
2012
2013
2013
let wrap_partial_application acc env apply_continuation (apply : IR.apply )
2014
- approx ~provided ~missing_arity ~first_complex_local_param
2014
+ approx ~provided ~missing_arity ~result_arity ~ first_complex_local_param
2015
2015
~contains_no_escaping_local_allocs =
2016
2016
(* In case of partial application, creates a wrapping function from scratch to
2017
2017
allow inlining and lifting *)
@@ -2047,7 +2047,8 @@ let wrap_partial_application acc env apply_continuation (apply : IR.apply)
2047
2047
continuation = return_continuation;
2048
2048
exn_continuation;
2049
2049
inlined = Lambda. Default_inlined ;
2050
- mode = result_mode
2050
+ mode = result_mode;
2051
+ return_arity = result_arity
2051
2052
}
2052
2053
(Some approx) ~replace_region: None
2053
2054
in
@@ -2090,11 +2091,10 @@ let wrap_partial_application acc env apply_continuation (apply : IR.apply)
2090
2091
Flambda_arity. cardinal missing_arity
2091
2092
- first_complex_local_param
2092
2093
})
2093
- ~params ~return: apply.return_arity ~return_continuation
2094
- ~exn_continuation ~my_region: apply.region ~body: fbody ~attr
2095
- ~loc: apply.loc ~free_idents_of_body ~closure_alloc_mode
2096
- ~first_complex_local_param ~contains_no_escaping_local_allocs
2097
- Recursive. Non_recursive ]
2094
+ ~params ~return: result_arity ~return_continuation ~exn_continuation
2095
+ ~my_region: apply.region ~body: fbody ~attr ~loc: apply.loc
2096
+ ~free_idents_of_body ~closure_alloc_mode ~first_complex_local_param
2097
+ ~contains_no_escaping_local_allocs Recursive. Non_recursive ]
2098
2098
in
2099
2099
let body acc env =
2100
2100
let arg = find_simple_from_id env wrapper_id in
@@ -2211,7 +2211,8 @@ type call_args_split =
2211
2211
| Exact of IR .simple list
2212
2212
| Partial_app of
2213
2213
{ provided : IR .simple list ;
2214
- missing_arity : Flambda_arity .t
2214
+ missing_arity : Flambda_arity .t ;
2215
+ result_arity : Flambda_arity .t
2215
2216
}
2216
2217
| Over_app of
2217
2218
{ full : IR .simple list ;
@@ -2228,6 +2229,7 @@ let close_apply acc env (apply : IR.apply) : Expr_with_acc.t =
2228
2229
let metadata = Code_or_metadata. code_metadata code in
2229
2230
Some
2230
2231
( Code_metadata. params_arity metadata,
2232
+ Code_metadata. result_arity metadata,
2231
2233
Code_metadata. is_tupled metadata,
2232
2234
Code_metadata. first_complex_local_param metadata,
2233
2235
Code_metadata. contains_no_escaping_local_allocs metadata )
@@ -2244,14 +2246,15 @@ let close_apply acc env (apply : IR.apply) : Expr_with_acc.t =
2244
2246
match code_info with
2245
2247
| None -> close_exact_or_unknown_apply acc env apply None ~replace_region: None
2246
2248
| Some
2247
- ( arity,
2249
+ ( params_arity,
2250
+ result_arity,
2248
2251
is_tupled,
2249
2252
first_complex_local_param,
2250
2253
contains_no_escaping_local_allocs ) -> (
2251
2254
let acc, args_with_arities = find_simples_and_arity acc env apply.args in
2252
2255
let args_arity = List. map snd args_with_arities in
2253
2256
let split_args =
2254
- let arity = Flambda_arity. to_list arity in
2257
+ let arity = Flambda_arity. to_list params_arity in
2255
2258
let split args arity =
2256
2259
let rec cut n l =
2257
2260
if n < = 0
@@ -2272,7 +2275,8 @@ let close_apply acc env (apply : IR.apply) : Expr_with_acc.t =
2272
2275
let _provided_arity, missing_arity = cut args_l arity in
2273
2276
Partial_app
2274
2277
{ provided = args;
2275
- missing_arity = Flambda_arity. create missing_arity
2278
+ missing_arity = Flambda_arity. create missing_arity;
2279
+ result_arity
2276
2280
}
2277
2281
else
2278
2282
let full, remaining = cut arity_l args in
@@ -2295,7 +2299,7 @@ let close_apply acc env (apply : IR.apply) : Expr_with_acc.t =
2295
2299
close_exact_or_unknown_apply acc env
2296
2300
{ apply with args; continuation = apply.continuation }
2297
2301
(Some approx) ~replace_region: None
2298
- | Partial_app { provided; missing_arity } ->
2302
+ | Partial_app { provided; missing_arity; result_arity } ->
2299
2303
(match apply.inlined with
2300
2304
| Always_inlined | Unroll _ ->
2301
2305
Location. prerr_warning
@@ -2305,7 +2309,7 @@ let close_apply acc env (apply : IR.apply) : Expr_with_acc.t =
2305
2309
inlined_attribute_on_partial_application_msg Inlined ))
2306
2310
| Never_inlined | Hint_inlined | Default_inlined -> () );
2307
2311
wrap_partial_application acc env apply.continuation apply approx ~provided
2308
- ~missing_arity ~first_complex_local_param
2312
+ ~missing_arity ~result_arity ~ first_complex_local_param
2309
2313
~contains_no_escaping_local_allocs
2310
2314
| Over_app { full; remaining; remaining_arity } ->
2311
2315
let full_args_call apply_continuation ~region acc =
0 commit comments