@@ -549,58 +549,50 @@ type binding =
549549 | Bind_value of value_binding list
550550 | Bind_module of Ident .t * string loc * module_expr
551551
552- let rec push_defaults loc bindings cases partial =
553- match cases with
554- | [
555- {
556- c_lhs = pat;
557- c_guard = None ;
558- c_rhs =
559- {exp_desc = Texp_function {arg_label; param; cases; partial}} as exp;
560- };
561- ] ->
562- let cases = push_defaults exp.exp_loc bindings cases partial in
563- [
564- {
565- c_lhs = pat;
566- c_guard = None ;
567- c_rhs =
568- {exp with exp_desc = Texp_function {arg_label; param; cases; partial}};
569- };
570- ]
571- | [
572- {
573- c_lhs = pat;
574- c_guard = None ;
575- c_rhs =
576- {
577- exp_attributes = [({txt = " #default" }, _)];
578- exp_desc =
579- Texp_let (Nonrecursive , binds, ({exp_desc = Texp_function _} as e2));
580- };
581- };
582- ] ->
552+ let rec push_defaults loc bindings case partial =
553+ match case with
554+ | {
555+ c_lhs = pat;
556+ c_guard = None ;
557+ c_rhs = {exp_desc = Texp_function {arg_label; param; case; partial}} as exp;
558+ } ->
559+ let case = push_defaults exp.exp_loc bindings case partial in
560+
561+ {
562+ c_lhs = pat;
563+ c_guard = None ;
564+ c_rhs =
565+ {exp with exp_desc = Texp_function {arg_label; param; case; partial}};
566+ }
567+ | {
568+ c_lhs = pat;
569+ c_guard = None ;
570+ c_rhs =
571+ {
572+ exp_attributes = [({txt = " #default" }, _)];
573+ exp_desc =
574+ Texp_let (Nonrecursive , binds, ({exp_desc = Texp_function _} as e2));
575+ };
576+ } ->
583577 push_defaults loc
584578 (Bind_value binds :: bindings)
585- [ {c_lhs = pat; c_guard = None ; c_rhs = e2}]
579+ {c_lhs = pat; c_guard = None ; c_rhs = e2}
586580 partial
587- | [
588- {
589- c_lhs = pat;
590- c_guard = None ;
591- c_rhs =
592- {
593- exp_attributes = [({txt = " #modulepat" }, _)];
594- exp_desc =
595- Texp_letmodule (id, name, mexpr, ({exp_desc = Texp_function _} as e2));
596- };
597- };
598- ] ->
581+ | {
582+ c_lhs = pat;
583+ c_guard = None ;
584+ c_rhs =
585+ {
586+ exp_attributes = [({txt = " #modulepat" }, _)];
587+ exp_desc =
588+ Texp_letmodule (id, name, mexpr, ({exp_desc = Texp_function _} as e2));
589+ };
590+ } ->
599591 push_defaults loc
600592 (Bind_module (id, name, mexpr) :: bindings)
601- [ {c_lhs = pat; c_guard = None ; c_rhs = e2}]
593+ {c_lhs = pat; c_guard = None ; c_rhs = e2}
602594 partial
603- | [ case] ->
595+ | case ->
604596 let exp =
605597 List. fold_left
606598 (fun exp binds ->
@@ -614,45 +606,7 @@ let rec push_defaults loc bindings cases partial =
614606 })
615607 case.c_rhs bindings
616608 in
617- [{case with c_rhs = exp}]
618- | {c_lhs = pat ; c_rhs = exp ; c_guard = _ } :: _ when bindings <> [] ->
619- let param = Typecore. name_pattern " param" cases in
620- let name = Ident. name param in
621- let exp =
622- {
623- exp with
624- exp_loc = loc;
625- exp_desc =
626- Texp_match
627- ( {
628- exp with
629- exp_type = pat.pat_type;
630- exp_desc =
631- Texp_ident
632- ( Path. Pident param,
633- mknoloc (Longident. Lident name),
634- {
635- val_type = pat.pat_type;
636- val_kind = Val_reg ;
637- val_attributes = [] ;
638- Types. val_loc = Location. none;
639- } );
640- },
641- cases,
642- [] ,
643- partial );
644- }
645- in
646- push_defaults loc bindings
647- [
648- {
649- c_lhs = {pat with pat_desc = Tpat_var (param, mknoloc name)};
650- c_guard = None ;
651- c_rhs = exp;
652- };
653- ]
654- Total
655- | _ -> cases
609+ {case with c_rhs = exp}
656610
657611(* Assertions *)
658612
@@ -716,15 +670,15 @@ and transl_exp0 (e : Typedtree.expression) : Lambda.lambda =
716670 | Texp_constant cst -> Lconst (Const_base cst)
717671 | Texp_let (rec_flag , pat_expr_list , body ) ->
718672 transl_let rec_flag pat_expr_list (transl_exp body)
719- | Texp_function {arg_label = _ ; param; cases ; partial} ->
673+ | Texp_function {arg_label = _ ; param; case ; partial} ->
720674 let async = has_async_attribute e in
721675 let directive =
722676 match extract_directive_for_fn e with
723677 | None -> None
724678 | Some (directive , _ ) -> Some directive
725679 in
726680 let params, body, return_unit =
727- let pl = push_defaults e.exp_loc [] cases partial in
681+ let pl = push_defaults e.exp_loc [] case partial in
728682 transl_function e.exp_loc partial param pl
729683 in
730684 let attr =
@@ -1088,32 +1042,28 @@ and transl_apply ?(inlined = Default_inline)
10881042 sargs)
10891043 : Lambda. lambda)
10901044
1091- and transl_function loc partial param cases =
1092- match cases with
1093- | [
1094- {
1095- c_lhs = pat;
1096- c_guard = None ;
1097- c_rhs =
1098- {
1099- exp_desc =
1100- Texp_function
1101- {arg_label = _; param = param'; cases; partial = partial'};
1102- } as exp;
1103- };
1104- ]
1045+ and transl_function loc partial param case =
1046+ match case with
1047+ | {
1048+ c_lhs = pat;
1049+ c_guard = None ;
1050+ c_rhs =
1051+ {
1052+ exp_desc =
1053+ Texp_function {arg_label = _; param = param'; case; partial = partial'};
1054+ } as exp;
1055+ }
11051056 when Parmatch. inactive ~partial pat && not (exp |> has_async_attribute) ->
11061057 let params, body, return_unit =
1107- transl_function exp.exp_loc partial' param' cases
1058+ transl_function exp.exp_loc partial' param' case
11081059 in
11091060 ( param :: params,
11101061 Matching. for_function loc None (Lvar param) [(pat, body)] partial,
11111062 return_unit )
1112- | {c_rhs = {exp_env; exp_type} ; _} :: _ ->
1063+ | {c_rhs = {exp_env; exp_type} ; _} ->
11131064 ( [param],
1114- Matching. for_function loc None (Lvar param) (transl_cases cases) partial,
1065+ Matching. for_function loc None (Lvar param) [transl_case case] partial,
11151066 is_base_type exp_env exp_type Predef. path_unit )
1116- | _ -> assert false
11171067
11181068and transl_let rec_flag pat_expr_list body =
11191069 match rec_flag with
0 commit comments