@@ -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 ;
@@ -307,10 +310,7 @@ module E = struct
307
310
variant ~loc ~attrs lab (map_opt (sub.expr sub) eo)
308
311
| Pexp_record (l , eo ) ->
309
312
record ~loc ~attrs
310
- (List. map
311
- (fun {lid; x = exp ; opt} ->
312
- {lid = map_loc sub lid; x = sub.expr sub exp; opt})
313
- l)
313
+ (List. map (sub.record_field sub) l)
314
314
(map_opt (sub.expr sub) eo)
315
315
| Pexp_field (e , lid ) ->
316
316
field ~loc ~attrs (sub.expr sub e) (map_loc sub lid)
@@ -393,12 +393,7 @@ module P = struct
393
393
construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p)
394
394
| Ppat_variant (l , p ) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p)
395
395
| Ppat_record (lpl , cf ) ->
396
- record ~loc ~attrs
397
- (List. map
398
- (fun {lid; x = pat ; opt} ->
399
- {lid = map_loc sub lid; x = sub.pat sub pat; opt})
400
- lpl)
401
- cf
396
+ record ~loc ~attrs (List. map (sub.record_field_pat sub) lpl) cf
402
397
| Ppat_array pl -> array ~loc ~attrs (List. map (sub.pat sub) pl)
403
398
| Ppat_or (p1 , p2 ) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2)
404
399
| Ppat_constraint (p , t ) ->
@@ -511,6 +506,12 @@ let default_mapper =
511
506
| PSig x -> PSig (this.signature this x)
512
507
| PTyp x -> PTyp (this.typ this x)
513
508
| PPat (x , g ) -> PPat (this.pat this x, map_opt (this.expr this) g));
509
+ record_field =
510
+ (fun this {lid; x; opt} ->
511
+ {lid = map_loc this lid; x = this.expr this x; opt});
512
+ record_field_pat =
513
+ (fun this {lid; x; opt} ->
514
+ {lid = map_loc this lid; x = this.pat this x; opt});
514
515
}
515
516
516
517
let rec extension_of_error {loc; msg; if_highlight; sub} =
0 commit comments