diff --git a/lib/Fmt_ast.ml b/lib/Fmt_ast.ml index b6961946ff..9c7e2c765a 100644 --- a/lib/Fmt_ast.ml +++ b/lib/Fmt_ast.ml @@ -2302,14 +2302,14 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens let pro = intro_epi $ fmt_if parens (str "(") - $ ( fmt_args_grouped ~epi:fmt_atrs e0 args_before - $ fmt_if parens (closing_paren c ~force ~offset:(-3)) ) + $ fmt_args_grouped ~epi:fmt_atrs e0 args_before in let label_sep = Params.Exp.fun_label_sep c.conf in let pro = pro $ break 1 0 $ fmt_label lbl label_sep in expr_epi $ hovbox 4 - (fmt_expression c ~pro ~box:false (sub_exp ~ctx last_arg)) + ( fmt_expression c ~pro ~box:false (sub_exp ~ctx last_arg) + $ fmt_if parens (closing_paren c ~force ~offset:(-3)) ) | _ -> let fmt_atrs = fmt_attributes c ~pre:(Break (1, -2)) pexp_attributes diff --git a/test/passing/refs.ahrefs/exp_grouping-parens.ml.ref b/test/passing/refs.ahrefs/exp_grouping-parens.ml.ref index 637e743e9f..347b3fffd7 100644 --- a/test/passing/refs.ahrefs/exp_grouping-parens.ml.ref +++ b/test/passing/refs.ahrefs/exp_grouping-parens.ml.ref @@ -578,3 +578,9 @@ let () = $ y in fooooooooooo x) + +let f () = + f + (g a (fun () -> + let x = y in + z)) diff --git a/test/passing/refs.ahrefs/exp_grouping.ml.ref b/test/passing/refs.ahrefs/exp_grouping.ml.ref index 46d5ac016f..054240dbbc 100644 --- a/test/passing/refs.ahrefs/exp_grouping.ml.ref +++ b/test/passing/refs.ahrefs/exp_grouping.ml.ref @@ -662,3 +662,10 @@ let () = in fooooooooooo x end + +let f () = + f + (g a begin fun () -> + let x = y in + z + end) diff --git a/test/passing/refs.default/exp_grouping-parens.ml.ref b/test/passing/refs.default/exp_grouping-parens.ml.ref index e3a2116f50..153fb6f88d 100644 --- a/test/passing/refs.default/exp_grouping-parens.ml.ref +++ b/test/passing/refs.default/exp_grouping-parens.ml.ref @@ -595,3 +595,9 @@ let () = $ y in fooooooooooo x) + +let f () = + f + (g a (fun () -> + let x = y in + z)) diff --git a/test/passing/refs.default/exp_grouping.ml.ref b/test/passing/refs.default/exp_grouping.ml.ref index ae14a21856..c4a1afb6e9 100644 --- a/test/passing/refs.default/exp_grouping.ml.ref +++ b/test/passing/refs.default/exp_grouping.ml.ref @@ -680,3 +680,10 @@ let () = in fooooooooooo x end + +let f () = + f + (g a begin fun () -> + let x = y in + z + end) diff --git a/test/passing/refs.janestreet/exp_grouping-parens.ml.ref b/test/passing/refs.janestreet/exp_grouping-parens.ml.ref index 1fb32db250..a221769b6a 100644 --- a/test/passing/refs.janestreet/exp_grouping-parens.ml.ref +++ b/test/passing/refs.janestreet/exp_grouping-parens.ml.ref @@ -677,3 +677,10 @@ let () = in fooooooooooo x) ;; + +let f () = + f + (g a (fun () -> + let x = y in + z)) +;; diff --git a/test/passing/refs.janestreet/exp_grouping.ml.ref b/test/passing/refs.janestreet/exp_grouping.ml.ref index 2c7f825df3..f66a0f6b0d 100644 --- a/test/passing/refs.janestreet/exp_grouping.ml.ref +++ b/test/passing/refs.janestreet/exp_grouping.ml.ref @@ -765,3 +765,11 @@ let () = fooooooooooo x end ;; + +let f () = + f + (g a begin fun () -> + let x = y in + z + end) +;; diff --git a/test/passing/refs.ocamlformat/exp_grouping-parens.ml.ref b/test/passing/refs.ocamlformat/exp_grouping-parens.ml.ref index ef1b600243..8f10b4c4b1 100644 --- a/test/passing/refs.ocamlformat/exp_grouping-parens.ml.ref +++ b/test/passing/refs.ocamlformat/exp_grouping-parens.ml.ref @@ -599,3 +599,9 @@ let () = $ y in fooooooooooo x ) + +let f () = + f + (g a (fun () -> + let x = y in + z ) ) diff --git a/test/passing/refs.ocamlformat/exp_grouping.ml.ref b/test/passing/refs.ocamlformat/exp_grouping.ml.ref index ceb4118ef7..b7534ade29 100644 --- a/test/passing/refs.ocamlformat/exp_grouping.ml.ref +++ b/test/passing/refs.ocamlformat/exp_grouping.ml.ref @@ -686,3 +686,10 @@ let () = in fooooooooooo x end + +let f () = + f + (g a begin fun () -> + let x = y in + z + end ) diff --git a/test/passing/tests/exp_grouping.ml b/test/passing/tests/exp_grouping.ml index 3ff154a3ea..352b4da5f7 100644 --- a/test/passing/tests/exp_grouping.ml +++ b/test/passing/tests/exp_grouping.ml @@ -547,3 +547,10 @@ let () = in fooooooooooo x end + +let f () = + f + (g a begin fun () -> + let x = y in + z + end )