@@ -166,32 +166,8 @@ type fun_param_kind =
166166 | NewTypes of {attrs : Parsetree .attributes ; locs : string Asttypes .loc list }
167167
168168let fun_expr expr =
169- (* Turns (type t, type u, type z) into "type t u z" *)
170- let rec collect_new_types acc return_expr =
171- match return_expr with
172- | {pexp_desc = Pexp_newtype (string_loc, return_expr); pexp_attributes = [] }
173- ->
174- collect_new_types (string_loc :: acc) return_expr
175- | return_expr -> (List. rev acc, return_expr)
176- in
177- let rec collect ~n_fun ~params expr =
169+ let rec collect_params ~n_fun ~params expr =
178170 match expr with
179- | {
180- pexp_desc =
181- Pexp_fun
182- {
183- arg_label = Nolabel ;
184- default = None ;
185- lhs = {ppat_desc = Ppat_var {txt = " __x" }};
186- rhs = {pexp_desc = Pexp_apply _};
187- };
188- } ->
189- (List. rev params, rewrite_underscore_apply expr)
190- | {pexp_desc = Pexp_newtype (string_loc, rest); pexp_attributes = attrs}
191- when n_fun = 0 ->
192- let string_locs, return_expr = collect_new_types [string_loc] rest in
193- let param = NewTypes {attrs; locs = string_locs} in
194- collect ~n_fun ~params: (param :: params) return_expr
195171 | {
196172 pexp_desc =
197173 Pexp_fun
@@ -202,23 +178,28 @@ let fun_expr expr =
202178 rhs = return_expr;
203179 arity;
204180 };
205- pexp_attributes = [] ;
181+ pexp_attributes = attrs ;
206182 }
207183 when arity = None || n_fun = 0 ->
208- let parameter =
209- Parameter {attrs = [] ; lbl; default_expr; pat = pattern}
210- in
211- collect ~n_fun: (n_fun + 1 ) ~params: (parameter :: params) return_expr
184+ let parameter = Parameter {attrs; lbl; default_expr; pat = pattern} in
185+ collect_params ~n_fun: (n_fun + 1 ) ~params: (parameter :: params) return_expr
212186 (* If a fun has an attribute, then it stops here and makes currying.
213187 i.e attributes outside of (...), uncurried `(.)` and `async` make currying *)
214- | {pexp_desc = Pexp_fun _ } -> (List. rev params, expr)
215- | expr when n_fun = 0 && Ast_uncurried. expr_is_uncurried_fun expr ->
216- let expr = Ast_uncurried. expr_extract_uncurried_fun expr in
217- collect ~n_fun ~params expr
218- | expr -> (List. rev params, expr)
188+ | _ -> (List. rev params, expr)
189+ in
190+ (* Turns (type t, type u, type z) into "type t u z" *)
191+ let rec collect_new_types acc return_expr =
192+ match return_expr with
193+ | {pexp_desc = Pexp_newtype (string_loc , return_expr )} ->
194+ collect_new_types (string_loc :: acc) return_expr
195+ | return_expr -> (List. rev acc, return_expr)
219196 in
220197 match expr with
221- | _ -> collect ~n_fun: 0 ~params: [] {expr with pexp_attributes = [] }
198+ | {pexp_desc = Pexp_newtype (string_loc , rest )} ->
199+ let string_locs, return_expr = collect_new_types [string_loc] rest in
200+ let param = NewTypes {attrs = [] ; locs = string_locs} in
201+ collect_params ~n_fun: 0 ~params: [param] return_expr
202+ | _ -> collect_params ~n_fun: 0 ~params: [] {expr with pexp_attributes = [] }
222203
223204let process_braces_attr expr =
224205 match expr.pexp_attributes with
0 commit comments