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
52
52
let pvb_pat = self.pat self vb.pvb_pat in
53
53
let pvb_expr = self.expr self vb.pvb_expr in
54
54
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 ->
57
57
begin match Ast_open_cxt. destruct_open_tuple pvb_expr [] with
58
58
| Some (wholes, es, tuple_attributes)
59
59
when
@@ -77,6 +77,22 @@ let flattern_tuple_pattern_vb
77
77
pvb_loc = vb.pvb_loc;
78
78
pvb_attributes} :: acc
79
79
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
+ )
80
96
| _ ->
81
97
{pvb_pat ;
82
98
pvb_expr ;
Original file line number Diff line number Diff line change @@ -167,13 +167,17 @@ let expr_mapper (self : mapper) (e : Parsetree.expression) =
167
167
pvb_attributes;
168
168
pvb_loc = _}], body)
169
169
->
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
177
181
(* let [@warning "a"] {a;b} = c in body
178
182
The attribute is attached to value binding,
179
183
after the transformation value binding does not exist so we attach
You can’t perform that action at this time.
0 commit comments