Skip to content

Commit 8c5fc5c

Browse files
fix one branch try
1 parent 55dbc49 commit 8c5fc5c

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

lib/Fmt_ast.ml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2564,18 +2564,22 @@ and fmt_expression c ?(box = true) ?(pro = noop) ?eol ?parens
25642564
&& c.conf.fmt_opts.break_cases.v <> `All
25652565
&& c.conf.fmt_opts.break_cases.v <> `Vertical ) ->
25662566
let cmts_before = Cmts.fmt_before c ?eol pexp_loc in
2567+
let pro_outer, pro_inner =
2568+
if Params.Exp.box_pro_with_match ~ctx0 ~parens then (noop, pro)
2569+
else (pro, noop)
2570+
in
25672571
(* side effects of Cmts.fmt_before before [fmt_pattern] is important *)
25682572
let xpc_rhs = sub_exp ~ctx pc_rhs in
25692573
let leading_cmt = Cmts.fmt_before c pc_lhs.ppat_loc in
25702574
let parens_here, parens_for_exp =
25712575
if c.conf.fmt_opts.leading_nested_match_parens.v then (false, None)
25722576
else (parenze_exp xpc_rhs, Some false)
25732577
in
2574-
cmts_before $ pro
2578+
cmts_before $ pro_outer
25752579
$ Params.Exp.wrap c.conf ~parens ~disambiguate:true
25762580
(hvbox 2
25772581
( hvbox 0
2578-
( str "try"
2582+
( hvbox 0 (pro_inner $ str "try")
25792583
$ fmt_extension_suffix c ext
25802584
$ fmt_attributes c pexp_attributes
25812585
$ break 1 2

test/passing/refs.default/exp_grouping-parens.ml.ref

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ let x =
319319
match Tbl.find dist_tbl (pv1, pv2) with
320320
| None ->
321321
(* FIXME: temporary hack to avoid Jane Street's annoying warnings. *)
322-
begin
323-
[@warning "-3"]
324-
try
322+
begin [@warning "-3"] try
325323
let path', dist = Dijkstra.shortest_path pgraph pv1 pv2 in
326324
let path = unwrap_path path' in
327325
Tbl.set dist_tbl ~key:(pv1, pv2) ~data:(path, dist);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ let x =
375375
match Tbl.find dist_tbl (pv1, pv2) with
376376
| None ->
377377
(* FIXME: temporary hack to avoid Jane Street's annoying warnings. *)
378-
begin
379-
[@warning "-3"]
380-
try
378+
begin [@warning "-3"] try
381379
let path', dist = Dijkstra.shortest_path pgraph pv1 pv2 in
382380
let path = unwrap_path path' in
383381
Tbl.set dist_tbl ~key:(pv1, pv2) ~data:(path, dist);

test/passing/refs.ocamlformat/exp_grouping-parens.ml.ref

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,7 @@ let x =
319319
match Tbl.find dist_tbl (pv1, pv2) with
320320
| None ->
321321
(* FIXME: temporary hack to avoid Jane Street's annoying warnings. *)
322-
begin
323-
[@warning "-3"]
324-
try
322+
begin [@warning "-3"] try
325323
let path', dist = Dijkstra.shortest_path pgraph pv1 pv2 in
326324
let path = unwrap_path path' in
327325
Tbl.set dist_tbl ~key:(pv1, pv2) ~data:(path, dist) ;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ let x =
375375
match Tbl.find dist_tbl (pv1, pv2) with
376376
| None ->
377377
(* FIXME: temporary hack to avoid Jane Street's annoying warnings. *)
378-
begin
379-
[@warning "-3"]
380-
try
378+
begin [@warning "-3"] try
381379
let path', dist = Dijkstra.shortest_path pgraph pv1 pv2 in
382380
let path = unwrap_path path' in
383381
Tbl.set dist_tbl ~key:(pv1, pv2) ~data:(path, dist) ;

0 commit comments

Comments
 (0)