@@ -48,6 +48,9 @@ type mapper = {
48
48
open_description : mapper -> open_description -> open_description ;
49
49
pat : mapper -> pattern -> pattern ;
50
50
payload : mapper -> payload -> payload ;
51
+ record_field :
52
+ mapper -> expression record_element -> expression record_element ;
53
+ record_field_pat : mapper -> pattern record_element -> pattern record_element ;
51
54
signature : mapper -> signature -> signature ;
52
55
signature_item : mapper -> signature_item -> signature_item ;
53
56
structure : mapper -> structure -> structure ;
@@ -305,10 +308,7 @@ module E = struct
305
308
variant ~loc ~attrs lab (map_opt (sub.expr sub) eo)
306
309
| Pexp_record (l , eo ) ->
307
310
record ~loc ~attrs
308
- (List. map
309
- (fun {lid; x = exp ; opt} ->
310
- {lid = map_loc sub lid; x = sub.expr sub exp; opt})
311
- l)
311
+ (List. map (sub.record_field sub) l)
312
312
(map_opt (sub.expr sub) eo)
313
313
| Pexp_field (e , lid ) ->
314
314
field ~loc ~attrs (sub.expr sub e) (map_loc sub lid)
@@ -391,12 +391,7 @@ module P = struct
391
391
construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p)
392
392
| Ppat_variant (l , p ) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p)
393
393
| Ppat_record (lpl , cf ) ->
394
- record ~loc ~attrs
395
- (List. map
396
- (fun {lid; x = pat ; opt} ->
397
- {lid = map_loc sub lid; x = sub.pat sub pat; opt})
398
- lpl)
399
- cf
394
+ record ~loc ~attrs (List. map (sub.record_field_pat sub) lpl) cf
400
395
| Ppat_array pl -> array ~loc ~attrs (List. map (sub.pat sub) pl)
401
396
| Ppat_or (p1 , p2 ) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2)
402
397
| Ppat_constraint (p , t ) ->
@@ -509,6 +504,12 @@ let default_mapper =
509
504
| PSig x -> PSig (this.signature this x)
510
505
| PTyp x -> PTyp (this.typ this x)
511
506
| PPat (x , g ) -> PPat (this.pat this x, map_opt (this.expr this) g));
507
+ record_field =
508
+ (fun this {lid; x; opt} ->
509
+ {lid = map_loc this lid; x = this.expr this x; opt});
510
+ record_field_pat =
511
+ (fun this {lid; x; opt} ->
512
+ {lid = map_loc this lid; x = this.pat this x; opt});
512
513
}
513
514
514
515
let rec extension_of_error {loc; msg; if_highlight; sub} =
0 commit comments