File tree Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Expand file tree Collapse file tree 2 files changed +29
-9
lines changed Original file line number Diff line number Diff line change @@ -52,8 +52,8 @@ let flattern_tuple_pattern_vb
5252 let pvb_pat = self.pat self vb.pvb_pat in
5353 let pvb_expr = self.expr self vb.pvb_expr in
5454 let pvb_attributes = self.attributes self vb.pvb_attributes in
55- match pvb_pat.ppat_desc with
56- | Ppat_tuple xs when List. for_all is_simple_pattern xs ->
55+ match pvb_pat.ppat_desc, pvb_expr.pexp_desc with
56+ | Ppat_tuple xs , _ when List. for_all is_simple_pattern xs ->
5757 begin match Ast_open_cxt. destruct_open_tuple pvb_expr [] with
5858 | Some (wholes, es, tuple_attributes)
5959 when
@@ -77,6 +77,22 @@ let flattern_tuple_pattern_vb
7777 pvb_loc = vb.pvb_loc;
7878 pvb_attributes} :: acc
7979 end
80+ | Ppat_record (lid_pats,_), Pexp_pack {pmod_desc= Pmod_ident id}
81+ ->
82+ Ext_list. map_append lid_pats acc (fun (lid ,pat ) ->
83+ match lid.txt with
84+ | Lident s ->
85+ {
86+ pvb_pat = pat;
87+ pvb_expr =
88+ Ast_helper.Exp. ident ~loc: lid.loc
89+ ({lid with txt = Ldot (id.txt,s)});
90+ pvb_attributes = [] ;
91+ pvb_loc = pat.ppat_loc;
92+ }
93+ | _ ->
94+ Location. raise_errorf ~loc: lid.loc " Not supported pattern match on modules"
95+ )
8096 | _ ->
8197 {pvb_pat ;
8298 pvb_expr ;
Original file line number Diff line number Diff line change @@ -167,13 +167,17 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
167167 pvb_attributes;
168168 pvb_loc = _}], body)
169169 ->
170- default_expr_mapper self
171- {e with
172- pexp_desc = Pexp_match (pvb_expr,
173- [{pc_lhs = p; pc_guard = None ;
174- pc_rhs = body}]);
175- pexp_attributes = e.pexp_attributes @ pvb_attributes
176- }
170+ begin match pvb_expr.pexp_desc with
171+ | Pexp_pack _ -> default_expr_mapper self e
172+ | _ ->
173+ default_expr_mapper self
174+ {e with
175+ pexp_desc = Pexp_match (pvb_expr,
176+ [{pc_lhs = p; pc_guard = None ;
177+ pc_rhs = body}]);
178+ pexp_attributes = e.pexp_attributes @ pvb_attributes
179+ }
180+ end
177181 (* let [@warning "a"] {a;b} = c in body
178182 The attribute is attached to value binding,
179183 after the transformation value binding does not exist so we attach
You can’t perform that action at this time.
0 commit comments