Skip to content

Commit

Permalink
Fix double-processing of pattern match case bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Jan 30, 2024
1 parent 0bf06d7 commit 5d7e8b8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ppx_minidebug.ml
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@ let traverse =
List.mapi (fun i { pc_lhs; pc_guard; pc_rhs } ->
let pc_guard = Option.map callback pc_guard in
let loc = pc_rhs.pexp_loc in
let pc_lhs, pc_rhs =
try
let vb =
debug_binding callback @@ A.value_binding ~loc ~pat:pc_lhs ~expr:pc_rhs
in
(vb.pvb_pat, vb.pvb_expr)
with Not_transforming -> (pc_lhs, pc_rhs)
in
let i = string_of_int i in
let pc_rhs =
[%expr
Expand All @@ -484,20 +492,15 @@ let traverse =
open_log_preamble ~brief:true
~message:("<" ^ kind ^ " -- branch " ^ i ^ ">")
~loc:pc_lhs.ppat_loc ()];
match [%e callback pc_rhs] with
match [%e pc_rhs] with
| match__result ->
Debug_runtime.close_log ();
match__result
| exception e ->
Debug_runtime.close_log ();
raise e]
in
try
let vb =
debug_binding callback @@ A.value_binding ~loc ~pat:pc_lhs ~expr:pc_rhs
in
{ pc_lhs = vb.pvb_pat; pc_guard; pc_rhs = vb.pvb_expr }
with Not_transforming -> { pc_lhs; pc_guard; pc_rhs })
{ pc_lhs; pc_guard; pc_rhs })
in
match e with
| { pexp_desc = Pexp_let (rec_flag, bindings, body); _ } ->
Expand Down

0 comments on commit 5d7e8b8

Please sign in to comment.