Skip to content

Commit c75452f

Browse files
fix infix apply begin function issue
1 parent e413ff8 commit c75452f

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

lib/Fmt_ast.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,8 @@ and fmt_infix_op_args c ~parens xexp op_args =
18751875
in
18761876
if Params.Exp.Infix_op_arg.dock c.conf xarg then
18771877
(* Indentation of docked fun or function start before the operator. *)
1878-
hovbox 2 (fmt_expression c ~parens ~box:false ~pro xarg)
1878+
hovbox ~name:"Infix_op_arg docked" 2
1879+
(fmt_expression c ~parens ~box:false ~pro xarg)
18791880
else
18801881
match xarg.ast.pexp_desc with
18811882
| Pexp_function _ | Pexp_beginend _ ->
@@ -2300,14 +2301,16 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
23002301
else Break
23012302
in
23022303
let pro =
2303-
pro
2304+
intro_epi
23042305
$ fmt_if parens (str "(")
23052306
$ ( fmt_args_grouped ~epi:fmt_atrs e0 args_before
23062307
$ fmt_if parens (closing_paren c ~force ~offset:(-3)) )
23072308
in
23082309
let label_sep = Params.Exp.fun_label_sep c.conf in
23092310
let pro = pro $ break 1 0 $ fmt_label lbl label_sep in
2310-
hovbox 4 (fmt_expression c ~pro ~box:false (sub_exp ~ctx last_arg))
2311+
expr_epi
2312+
$ hovbox 4
2313+
(fmt_expression c ~pro ~box:false (sub_exp ~ctx last_arg))
23112314
| _ ->
23122315
let fmt_atrs =
23132316
fmt_attributes c ~pre:(Break (1, -2)) pexp_attributes

lib/Params.ml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,11 @@ module Exp = struct
145145
| Pexp_apply (_, args) -> (
146146
(* Rhs is an apply and it ends with a [fun]. *)
147147
match List.last_exn args with
148-
| _, {pexp_desc= Pexp_function _; _} -> true
148+
| _, {pexp_desc= Pexp_function _; _}
149+
|( _
150+
, { pexp_desc= Pexp_beginend ({pexp_desc= Pexp_function _; _}, _)
151+
; _ } ) ->
152+
true
149153
| _ -> false )
150154
| Pexp_match _ | Pexp_try _ -> true
151155
| _ -> false

test/passing/refs.janestreet/attributes.ml.ref

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,10 @@ let () =
443443
let () =
444444
S.ntyp Cbor_type.Reserved
445445
@@ S.tok begin[@warning "-4"] fun ev ->
446-
match ev with
447-
| Cbor_event.Reserved int -> Some int
448-
| _ -> None
449-
end
446+
match ev with
447+
| Cbor_event.Reserved int -> Some int
448+
| _ -> None
449+
end
450450
in
451451
()
452452
;;

test/passing/refs.janestreet/exp_grouping.ml.ref

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -731,31 +731,25 @@ let _ =
731731
let () =
732732
fooooo
733733
|>>>>> List.iter begin fun a ->
734-
let x =
735-
some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y
736-
in
737-
fooooooooooo x
738-
end
734+
let x = some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y in
735+
fooooooooooo x
736+
end
739737
;;
740738

741739
let () =
742740
fooooo
743741
|>>>>> List.iter begin fun aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ->
744-
let x =
745-
some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y
746-
in
747-
fooooooooooo x
748-
end
742+
let x = some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y in
743+
fooooooooooo x
744+
end
749745
;;
750746

751747
let () =
752748
fooooo
753749
|>>>>> List.iter begin fun a ->
754-
let x =
755-
some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y
756-
in
757-
fooooooooooo x
758-
end
750+
let x = some_really_really_really_long_name_that_doesn't_fit_on_the_line $ y in
751+
fooooooooooo x
752+
end
759753
;;
760754

761755
let () =

0 commit comments

Comments
 (0)