From b943909a75d49183af8e0b534d3304013f407e7d Mon Sep 17 00:00:00 2001 From: EmileTrotignon Date: Fri, 25 Apr 2025 21:50:35 +0200 Subject: [PATCH 1/2] make `map ~a:(fun` and `map (fun` consistent --- lib/Params.ml | 16 ++----- .../break_fun_decl-fit_or_vertical.ml.ref | 8 +++- .../refs.ahrefs/break_fun_decl-smart.ml.ref | 8 +++- .../refs.ahrefs/break_fun_decl-wrap.ml.ref | 8 +++- .../passing/refs.ahrefs/break_fun_decl.ml.ref | 8 +++- test/passing/refs.ahrefs/class_expr.ml.err | 0 test/passing/refs.ahrefs/class_expr.ml.ref | 3 +- test/passing/refs.ahrefs/exp_grouping.ml.ref | 9 +--- .../fun_decl-no-wrap-fun-args.ml.err | 2 +- .../fun_decl-no-wrap-fun-args.ml.ref | 48 ++++++++++--------- test/passing/refs.ahrefs/fun_decl.ml.ref | 6 ++- test/passing/refs.ahrefs/js_source.ml.err | 2 +- test/passing/refs.ahrefs/js_source.ml.ref | 6 ++- .../break_fun_decl-fit_or_vertical.ml.ref | 8 +++- .../refs.default/break_fun_decl-smart.ml.ref | 8 +++- .../refs.default/break_fun_decl-wrap.ml.ref | 8 +++- .../refs.default/break_fun_decl.ml.ref | 8 +++- test/passing/refs.default/class_expr.ml.err | 2 +- test/passing/refs.default/class_expr.ml.ref | 3 +- test/passing/refs.default/exp_grouping.ml.ref | 9 +--- .../fun_decl-no-wrap-fun-args.ml.ref | 20 ++++---- test/passing/refs.default/fun_decl.ml.ref | 6 ++- test/passing/refs.default/js_source.ml.err | 2 +- test/passing/refs.default/js_source.ml.ref | 6 ++- .../break_fun_decl-fit_or_vertical.ml.ref | 8 +++- .../break_fun_decl-smart.ml.ref | 8 +++- .../break_fun_decl-wrap.ml.ref | 8 +++- .../refs.ocamlformat/break_fun_decl.ml.ref | 8 +++- .../refs.ocamlformat/class_expr.ml.ref | 3 +- .../refs.ocamlformat/exp_grouping.ml.ref | 9 +--- .../fun_decl-no-wrap-fun-args.ml.ref | 20 ++++---- test/passing/refs.ocamlformat/fun_decl.ml.ref | 6 ++- .../passing/refs.ocamlformat/js_source.ml.err | 4 +- .../passing/refs.ocamlformat/js_source.ml.ref | 6 ++- 34 files changed, 167 insertions(+), 117 deletions(-) create mode 100644 test/passing/refs.ahrefs/class_expr.ml.err diff --git a/lib/Params.ml b/lib/Params.ml index 29ae8be40e..e4fa82177f 100644 --- a/lib/Params.ml +++ b/lib/Params.ml @@ -174,17 +174,10 @@ module Exp = struct | Some ((Labelled _ | Optional _), _, _) -> true | _ -> false in - let is_ctx_beginend = - match ctx0 with - | Exp {pexp_desc= Pexp_beginend _; _} -> true - | _ -> false - in if Conf.(c.fmt_opts.ocp_indent_compat.v) then if last_arg || is_labelled_arg then break 1 2 else str " " else if is_labelled_arg then break 1 2 - else if last_arg then break 1 0 - else if is_ctx_beginend then break 1 0 - else str " " + else break 1 0 let box_fun_decl_args ~ctx ~ctx0 ?(last_arg = false) ?epi c ~parens ~kw ~args ~annot = @@ -215,11 +208,8 @@ module Exp = struct match ctx_is_apply_and_exp_is_arg ~ctx ~ctx0 with | Some (_, _, true) -> (* Is last arg. *) hvbox ~name (if parens then 0 else 2) - | Some (Nolabel, _, false) -> - (* TODO: Inconsistent formatting of fun args. *) - hovbox ~name 0 - | Some ((Labelled _ | Optional _), _, false) -> hvbox ~name 0 - | None -> Fn.id + | Some (_, _, false) -> hvbox ~name 0 + | None -> hvbox ~name 0 in (box, not c.fmt_opts.wrap_fun_args.v) in diff --git a/test/passing/refs.ahrefs/break_fun_decl-fit_or_vertical.ml.ref b/test/passing/refs.ahrefs/break_fun_decl-fit_or_vertical.ml.ref index cb77a167ed..72e9e580b2 100644 --- a/test/passing/refs.ahrefs/break_fun_decl-fit_or_vertical.ml.ref +++ b/test/passing/refs.ahrefs/break_fun_decl-fit_or_vertical.ml.ref @@ -136,8 +136,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.ahrefs/break_fun_decl-smart.ml.ref b/test/passing/refs.ahrefs/break_fun_decl-smart.ml.ref index a91333ef8b..eb3019938a 100644 --- a/test/passing/refs.ahrefs/break_fun_decl-smart.ml.ref +++ b/test/passing/refs.ahrefs/break_fun_decl-smart.ml.ref @@ -129,8 +129,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.ahrefs/break_fun_decl-wrap.ml.ref b/test/passing/refs.ahrefs/break_fun_decl-wrap.ml.ref index 6a4565a19b..a938d4710a 100644 --- a/test/passing/refs.ahrefs/break_fun_decl-wrap.ml.ref +++ b/test/passing/refs.ahrefs/break_fun_decl-wrap.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.ahrefs/break_fun_decl.ml.ref b/test/passing/refs.ahrefs/break_fun_decl.ml.ref index 6a4565a19b..a938d4710a 100644 --- a/test/passing/refs.ahrefs/break_fun_decl.ml.ref +++ b/test/passing/refs.ahrefs/break_fun_decl.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.ahrefs/class_expr.ml.err b/test/passing/refs.ahrefs/class_expr.ml.err new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/passing/refs.ahrefs/class_expr.ml.ref b/test/passing/refs.ahrefs/class_expr.ml.ref index ff81f87b4e..15a7c71240 100644 --- a/test/passing/refs.ahrefs/class_expr.ml.ref +++ b/test/passing/refs.ahrefs/class_expr.ml.ref @@ -9,7 +9,8 @@ class c (* xx *) i (* yy *) = x class c = object method class_infos : 'a. ('a -> 'res) -> 'a class_infos -> 'res = - fun _a + fun + _a { pci_virt; pci_params; pci_name; pci_expr; pci_loc; pci_attributes } -> let pci_virt = self#virtual_flag pci_virt in let pci_params = self#list in diff --git a/test/passing/refs.ahrefs/exp_grouping.ml.ref b/test/passing/refs.ahrefs/exp_grouping.ml.ref index 46d5ac016f..a689a687ab 100644 --- a/test/passing/refs.ahrefs/exp_grouping.ml.ref +++ b/test/passing/refs.ahrefs/exp_grouping.ml.ref @@ -394,9 +394,7 @@ let v = let v = map x begin fun - x - arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg - -> + x arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg -> y end @@ -457,10 +455,7 @@ let _ = let _ = lazy begin fun - xxxxxxxxxxxxxxxxxxxxxxx - yyyyyyyyyyyyyyyyyyy - zzzzzzzzzzzzzzzzzzzzzzzz - -> + xxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzzzzz -> print_endline xxxxxxxxx; f xxxxxxxxxx yyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzz end diff --git a/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.err b/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.err index 80a2320be6..e154f23912 100644 --- a/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.err +++ b/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.err @@ -1 +1 @@ -Warning: fun_decl-no-wrap-fun-args.ml:39 exceeds the margin +Warning: fun_decl-no-wrap-fun-args.ml:41 exceeds the margin diff --git a/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.ref b/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.ref index e091d0299f..fdfb6c83a0 100644 --- a/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.ref +++ b/test/passing/refs.ahrefs/fun_decl-no-wrap-fun-args.ml.ref @@ -5,25 +5,27 @@ let _ = fun (x : int) : int -> (some_large_computation : int) let fooo = List.foooo ~f:(fun foooo foooo : bool -> foooooooooooooooooooooo) let _ = - fun (x : int) - (x : int) - (x : int) - (x : int) - (x : int) - : - fooooooooooooooooooooooooooo foooooooooooooo foooooooooo -> + fun + (x : int) + (x : int) + (x : int) + (x : int) + (x : int) + : + fooooooooooooooooooooooooooo foooooooooooooo foooooooooo -> some_large_computation let _ = - fun (x : int) - (x : int) - (x : int) - (x : int) - (x : int) - (x : int) - (x : int) - : - fooooooooooooooooooooooooooo foooooooooooooo foooooooooo -> + fun + (x : int) + (x : int) + (x : int) + (x : int) + (x : int) + (x : int) + (x : int) + : + fooooooooooooooooooooooooooo foooooooooooooo foooooooooo -> some_large_computation let () = @@ -94,17 +96,19 @@ let _ = let _ = let _ = () in - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () let _ = print_endline "foo"; - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () diff --git a/test/passing/refs.ahrefs/fun_decl.ml.ref b/test/passing/refs.ahrefs/fun_decl.ml.ref index b335e2636b..c035677c2f 100644 --- a/test/passing/refs.ahrefs/fun_decl.ml.ref +++ b/test/passing/refs.ahrefs/fun_decl.ml.ref @@ -82,7 +82,8 @@ let _ = let _ = let _ = () in - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in @@ -90,7 +91,8 @@ let _ = let _ = print_endline "foo"; - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in diff --git a/test/passing/refs.ahrefs/js_source.ml.err b/test/passing/refs.ahrefs/js_source.ml.err index aefce07998..5ce0ab91f5 100644 --- a/test/passing/refs.ahrefs/js_source.ml.err +++ b/test/passing/refs.ahrefs/js_source.ml.err @@ -2,4 +2,4 @@ Warning: js_source.ml:136 exceeds the margin Warning: js_source.ml:170 exceeds the margin Warning: js_source.ml:243 exceeds the margin Warning: js_source.ml:255 exceeds the margin -Warning: js_source.ml:862 exceeds the margin +Warning: js_source.ml:864 exceeds the margin diff --git a/test/passing/refs.ahrefs/js_source.ml.ref b/test/passing/refs.ahrefs/js_source.ml.ref index e63dce0ed9..04e69d0686 100644 --- a/test/passing/refs.ahrefs/js_source.ml.ref +++ b/test/passing/refs.ahrefs/js_source.ml.ref @@ -587,7 +587,8 @@ let _ = let _ = let x = x in - fun foooooooooooooooooo + fun + foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo @@ -645,7 +646,8 @@ module M = let _ = Some - (fun fooooooooooooooooooooooooooooooo + (fun + fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo -> foo) diff --git a/test/passing/refs.default/break_fun_decl-fit_or_vertical.ml.ref b/test/passing/refs.default/break_fun_decl-fit_or_vertical.ml.ref index 44bb2baee8..97743270f1 100644 --- a/test/passing/refs.default/break_fun_decl-fit_or_vertical.ml.ref +++ b/test/passing/refs.default/break_fun_decl-fit_or_vertical.ml.ref @@ -136,8 +136,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.default/break_fun_decl-smart.ml.ref b/test/passing/refs.default/break_fun_decl-smart.ml.ref index 82a8ac5a0f..e116fd69a0 100644 --- a/test/passing/refs.default/break_fun_decl-smart.ml.ref +++ b/test/passing/refs.default/break_fun_decl-smart.ml.ref @@ -129,8 +129,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.default/break_fun_decl-wrap.ml.ref b/test/passing/refs.default/break_fun_decl-wrap.ml.ref index bb41950f18..f1b35f2e9e 100644 --- a/test/passing/refs.default/break_fun_decl-wrap.ml.ref +++ b/test/passing/refs.default/break_fun_decl-wrap.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.default/break_fun_decl.ml.ref b/test/passing/refs.default/break_fun_decl.ml.ref index bb41950f18..f1b35f2e9e 100644 --- a/test/passing/refs.default/break_fun_decl.ml.ref +++ b/test/passing/refs.default/break_fun_decl.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> ()) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> ()) foo let new_specialised_args = diff --git a/test/passing/refs.default/class_expr.ml.err b/test/passing/refs.default/class_expr.ml.err index ba51e1bdbe..53f5b8e594 100644 --- a/test/passing/refs.default/class_expr.ml.err +++ b/test/passing/refs.default/class_expr.ml.err @@ -1 +1 @@ -Warning: class_expr.ml:9 exceeds the margin +Warning: class_expr.ml:10 exceeds the margin diff --git a/test/passing/refs.default/class_expr.ml.ref b/test/passing/refs.default/class_expr.ml.ref index e8df8add63..2999fe488d 100644 --- a/test/passing/refs.default/class_expr.ml.ref +++ b/test/passing/refs.default/class_expr.ml.ref @@ -6,7 +6,8 @@ class c (* xx *) i (* yy *) = x class c = object method class_infos : 'a. ('a -> 'res) -> 'a class_infos -> 'res = - fun _a + fun + _a { pci_virt; pci_params; pci_name; pci_expr; pci_loc; pci_attributes } -> let pci_virt = self#virtual_flag pci_virt in let pci_params = self#list in diff --git a/test/passing/refs.default/exp_grouping.ml.ref b/test/passing/refs.default/exp_grouping.ml.ref index ae14a21856..1a64db7e1d 100644 --- a/test/passing/refs.default/exp_grouping.ml.ref +++ b/test/passing/refs.default/exp_grouping.ml.ref @@ -411,9 +411,7 @@ let v = let v = map x begin fun - x - arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg - -> + x arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg -> y end @@ -474,10 +472,7 @@ let _ = let _ = lazy begin fun - xxxxxxxxxxxxxxxxxxxxxxx - yyyyyyyyyyyyyyyyyyy - zzzzzzzzzzzzzzzzzzzzzzzz - -> + xxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzzzzz -> print_endline xxxxxxxxx; f xxxxxxxxxx yyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzz end diff --git a/test/passing/refs.default/fun_decl-no-wrap-fun-args.ml.ref b/test/passing/refs.default/fun_decl-no-wrap-fun-args.ml.ref index 0b88f987a6..f9b9b9c761 100644 --- a/test/passing/refs.default/fun_decl-no-wrap-fun-args.ml.ref +++ b/test/passing/refs.default/fun_decl-no-wrap-fun-args.ml.ref @@ -3,7 +3,8 @@ let _ = fun (x : int) : int -> (some_large_computation : int) let fooo = List.foooo ~f:(fun foooo foooo : bool -> foooooooooooooooooooooo) let _ = - fun (x : int) + fun + (x : int) (x : int) (x : int) (x : int) @@ -13,7 +14,8 @@ let _ = some_large_computation let _ = - fun (x : int) + fun + (x : int) (x : int) (x : int) (x : int) @@ -94,17 +96,19 @@ let _ = let _ = let _ = () in - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () let _ = print_endline "foo"; - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () diff --git a/test/passing/refs.default/fun_decl.ml.ref b/test/passing/refs.default/fun_decl.ml.ref index aa3d2f8d8f..671a704a59 100644 --- a/test/passing/refs.default/fun_decl.ml.ref +++ b/test/passing/refs.default/fun_decl.ml.ref @@ -80,7 +80,8 @@ let _ = let _ = let _ = () in - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in @@ -88,7 +89,8 @@ let _ = let _ = print_endline "foo"; - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in diff --git a/test/passing/refs.default/js_source.ml.err b/test/passing/refs.default/js_source.ml.err index e2a2cb4b3b..14f8073183 100644 --- a/test/passing/refs.default/js_source.ml.err +++ b/test/passing/refs.default/js_source.ml.err @@ -4,4 +4,4 @@ Warning: js_source.ml:224 exceeds the margin Warning: js_source.ml:229 exceeds the margin Warning: js_source.ml:240 exceeds the margin Warning: js_source.ml:328 exceeds the margin -Warning: js_source.ml:814 exceeds the margin +Warning: js_source.ml:816 exceeds the margin diff --git a/test/passing/refs.default/js_source.ml.ref b/test/passing/refs.default/js_source.ml.ref index c71b146064..200ef70a38 100644 --- a/test/passing/refs.default/js_source.ml.ref +++ b/test/passing/refs.default/js_source.ml.ref @@ -560,7 +560,8 @@ let _ = let _ = let x = x in - fun foooooooooooooooooo + fun + foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo @@ -613,7 +614,8 @@ module M = let _ = Some - (fun fooooooooooooooooooooooooooooooo + (fun + fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo -> foo) diff --git a/test/passing/refs.ocamlformat/break_fun_decl-fit_or_vertical.ml.ref b/test/passing/refs.ocamlformat/break_fun_decl-fit_or_vertical.ml.ref index a0bc0cd4f4..f80f034ace 100644 --- a/test/passing/refs.ocamlformat/break_fun_decl-fit_or_vertical.ml.ref +++ b/test/passing/refs.ocamlformat/break_fun_decl-fit_or_vertical.ml.ref @@ -136,8 +136,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> () ) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> () ) foo let new_specialised_args = diff --git a/test/passing/refs.ocamlformat/break_fun_decl-smart.ml.ref b/test/passing/refs.ocamlformat/break_fun_decl-smart.ml.ref index 9bb0fad0c4..88339e6202 100644 --- a/test/passing/refs.ocamlformat/break_fun_decl-smart.ml.ref +++ b/test/passing/refs.ocamlformat/break_fun_decl-smart.ml.ref @@ -129,8 +129,12 @@ let f let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> () ) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> () ) foo let new_specialised_args = diff --git a/test/passing/refs.ocamlformat/break_fun_decl-wrap.ml.ref b/test/passing/refs.ocamlformat/break_fun_decl-wrap.ml.ref index 57152dcde5..57c38c69da 100644 --- a/test/passing/refs.ocamlformat/break_fun_decl-wrap.ml.ref +++ b/test/passing/refs.ocamlformat/break_fun_decl-wrap.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> () ) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> () ) foo let new_specialised_args = diff --git a/test/passing/refs.ocamlformat/break_fun_decl.ml.ref b/test/passing/refs.ocamlformat/break_fun_decl.ml.ref index 57152dcde5..57c38c69da 100644 --- a/test/passing/refs.ocamlformat/break_fun_decl.ml.ref +++ b/test/passing/refs.ocamlformat/break_fun_decl.ml.ref @@ -110,8 +110,12 @@ let f (module Store : Irmin.Generic_key.S with type repo = repo) let new_specialised_args = Variable.Map.mapi - (fun new_inner_var______ (definition : Definition.t) : - Flambda.specialised_to -> () ) + (fun + new_inner_var______ + (definition : Definition.t) + : + Flambda.specialised_to + -> () ) foo let new_specialised_args = diff --git a/test/passing/refs.ocamlformat/class_expr.ml.ref b/test/passing/refs.ocamlformat/class_expr.ml.ref index 9872e648c7..b8a562f57d 100644 --- a/test/passing/refs.ocamlformat/class_expr.ml.ref +++ b/test/passing/refs.ocamlformat/class_expr.ml.ref @@ -9,7 +9,8 @@ class c (* xx *) i (* yy *) = x class c = object method class_infos : 'a. ('a -> 'res) -> 'a class_infos -> 'res = - fun _a + fun + _a {pci_virt; pci_params; pci_name; pci_expr; pci_loc; pci_attributes} -> let pci_virt = self#virtual_flag pci_virt in let pci_params = self#list in diff --git a/test/passing/refs.ocamlformat/exp_grouping.ml.ref b/test/passing/refs.ocamlformat/exp_grouping.ml.ref index ceb4118ef7..adc1f9267a 100644 --- a/test/passing/refs.ocamlformat/exp_grouping.ml.ref +++ b/test/passing/refs.ocamlformat/exp_grouping.ml.ref @@ -412,9 +412,7 @@ let v = let v = map x begin fun - x - arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg - -> + x arggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg -> y end @@ -472,10 +470,7 @@ let _ = let _ = lazy begin fun - xxxxxxxxxxxxxxxxxxxxxxx - yyyyyyyyyyyyyyyyyyy - zzzzzzzzzzzzzzzzzzzzzzzz - -> + xxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzzzzz -> print_endline xxxxxxxxx ; f xxxxxxxxxx yyyyyyyyyyyyy zzzzzzzzzzzzzzzzzzzzz end diff --git a/test/passing/refs.ocamlformat/fun_decl-no-wrap-fun-args.ml.ref b/test/passing/refs.ocamlformat/fun_decl-no-wrap-fun-args.ml.ref index 4e8f3237e4..2a1bc221f9 100644 --- a/test/passing/refs.ocamlformat/fun_decl-no-wrap-fun-args.ml.ref +++ b/test/passing/refs.ocamlformat/fun_decl-no-wrap-fun-args.ml.ref @@ -5,7 +5,8 @@ let _ = fun (x : int) : int -> (some_large_computation : int) let fooo = List.foooo ~f:(fun foooo foooo : bool -> foooooooooooooooooooooo) let _ = - fun (x : int) + fun + (x : int) (x : int) (x : int) (x : int) @@ -15,7 +16,8 @@ let _ = some_large_computation let _ = - fun (x : int) + fun + (x : int) (x : int) (x : int) (x : int) @@ -100,17 +102,19 @@ let _ = let _ = let _ = () in - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () let _ = print_endline "foo" ; - fun (context : Context.t) - ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) - -> + fun + (context : Context.t) + ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) + -> let _ = () in () diff --git a/test/passing/refs.ocamlformat/fun_decl.ml.ref b/test/passing/refs.ocamlformat/fun_decl.ml.ref index d61788f174..c6881564f4 100644 --- a/test/passing/refs.ocamlformat/fun_decl.ml.ref +++ b/test/passing/refs.ocamlformat/fun_decl.ml.ref @@ -86,7 +86,8 @@ let _ = let _ = let _ = () in - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in @@ -94,7 +95,8 @@ let _ = let _ = print_endline "foo" ; - fun (context : Context.t) + fun + (context : Context.t) ~(local_bins : origin Appendable_list.t Filename.Map.t Memo.Lazy.t) -> let _ = () in diff --git a/test/passing/refs.ocamlformat/js_source.ml.err b/test/passing/refs.ocamlformat/js_source.ml.err index 96ee325fb2..366aeca5d8 100644 --- a/test/passing/refs.ocamlformat/js_source.ml.err +++ b/test/passing/refs.ocamlformat/js_source.ml.err @@ -5,5 +5,5 @@ Warning: js_source.ml:154 exceeds the margin Warning: js_source.ml:219 exceeds the margin Warning: js_source.ml:224 exceeds the margin Warning: js_source.ml:235 exceeds the margin -Warning: js_source.ml:637 exceeds the margin -Warning: js_source.ml:837 exceeds the margin +Warning: js_source.ml:639 exceeds the margin +Warning: js_source.ml:839 exceeds the margin diff --git a/test/passing/refs.ocamlformat/js_source.ml.ref b/test/passing/refs.ocamlformat/js_source.ml.ref index a99ee97996..bc9001ca1d 100644 --- a/test/passing/refs.ocamlformat/js_source.ml.ref +++ b/test/passing/refs.ocamlformat/js_source.ml.ref @@ -572,7 +572,8 @@ let _ = let _ = let x = x in - fun foooooooooooooooooo + fun + foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo foooooooooooooooooo @@ -627,7 +628,8 @@ module M = let _ = Some - (fun fooooooooooooooooooooooooooooooo + (fun + fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo fooooooooooooooooooooooooooooooo -> foo ) From 56358ce4b6635bb4b9efa562aa0a0f2b70c5b33d Mon Sep 17 00:00:00 2001 From: EmileTrotignon Date: Fri, 25 Apr 2025 21:59:28 +0200 Subject: [PATCH 2/2] changelog --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 5363e58e83..4dd58b466f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -80,6 +80,9 @@ profile. This started with version 0.26.0. - Fix a crash where `type%e nonrec t = t` was formatted as `type nonrec%e t = t`, which is invalid syntax. (#2712, @EmileTrotignon) +- \* The formatting of `f (fun` is now consistent with `f ~a:(fun`. + (#2706, @EmileTrotignon) + ### Changed - `|> begin`, `~arg:begin`, `begin if`, `lazy begin`, `begin match`,