@@ -141,9 +141,17 @@ let default_action ~saturated failaction =
141
141
let get_const_name i (sw_names : Lambda.switch_names option ) =
142
142
match sw_names with None -> None | Some { consts } -> Some consts.(i)
143
143
144
- let get_block_name i (sw_names : Lambda.switch_names option ) =
144
+ let get_block i (sw_names : Lambda.switch_names option ) =
145
145
match sw_names with None -> None | Some { blocks } -> Some blocks.(i)
146
146
147
+ let get_tag_name (sw_names : Lambda.switch_names option ) =
148
+ match sw_names with
149
+ | None -> Js_dump_lit. tag
150
+ | Some { blocks } ->
151
+ (match Array. find_opt (fun {Lambda. tag_name} -> tag_name <> None ) blocks with
152
+ | Some {tag_name = Some s } -> s
153
+ | _ -> Js_dump_lit. tag
154
+ )
147
155
148
156
let has_null_undefined_other (sw_names : Lambda.switch_names option ) =
149
157
let (null, undefined, other) = (ref false , ref false , ref false ) in
@@ -628,7 +636,11 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch)
628
636
default_action ~saturated: sw_blocks_full sw_failaction
629
637
in
630
638
let get_const_name i = get_const_name i sw_names in
631
- let get_block_name i = get_block_name i sw_names in
639
+ let get_block i = get_block i sw_names in
640
+ let get_block_name i = match get_block i with
641
+ | None -> None
642
+ | Some {cstr_name} -> Some cstr_name in
643
+ let tag_name = get_tag_name sw_names in
632
644
let compile_whole (cxt : Lam_compile_context.t ) =
633
645
match
634
646
compile_lambda { cxt with continuation = NeedValue Not_tail } switch_arg
@@ -638,7 +650,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch)
638
650
block
639
651
@
640
652
if sw_consts_full && sw_consts = [] then
641
- compile_cases cxt (E. tag e) sw_blocks sw_blocks_default get_block_name
653
+ compile_cases cxt (E. tag ~name: tag_name e) sw_blocks sw_blocks_default get_block_name
642
654
else if sw_blocks_full && sw_blocks = [] then
643
655
compile_cases cxt e sw_consts sw_num_default get_const_name
644
656
else
@@ -648,7 +660,7 @@ and compile_switch (switch_arg : Lam.t) (sw : Lam.lambda_switch)
648
660
(compile_cases cxt e sw_consts sw_num_default get_const_name)
649
661
(* default still needed, could simplified*)
650
662
~else_:
651
- (compile_cases cxt (E. tag e) sw_blocks sw_blocks_default
663
+ (compile_cases cxt (E. tag ~name: tag_name e) sw_blocks sw_blocks_default
652
664
get_block_name)
653
665
in
654
666
match e.expression_desc with
0 commit comments