@@ -48,6 +48,9 @@ type mapper = {
4848 open_description : mapper -> open_description -> open_description ;
4949 pat : mapper -> pattern -> pattern ;
5050 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 ;
5154 signature : mapper -> signature -> signature ;
5255 signature_item : mapper -> signature_item -> signature_item ;
5356 structure : mapper -> structure -> structure ;
@@ -305,10 +308,7 @@ module E = struct
305308 variant ~loc ~attrs lab (map_opt (sub.expr sub) eo)
306309 | Pexp_record (l , eo ) ->
307310 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)
312312 (map_opt (sub.expr sub) eo)
313313 | Pexp_field (e , lid ) ->
314314 field ~loc ~attrs (sub.expr sub e) (map_loc sub lid)
@@ -391,12 +391,7 @@ module P = struct
391391 construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p)
392392 | Ppat_variant (l , p ) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p)
393393 | 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
400395 | Ppat_array pl -> array ~loc ~attrs (List. map (sub.pat sub) pl)
401396 | Ppat_or (p1 , p2 ) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2)
402397 | Ppat_constraint (p , t ) ->
@@ -509,6 +504,12 @@ let default_mapper =
509504 | PSig x -> PSig (this.signature this x)
510505 | PTyp x -> PTyp (this.typ this x)
511506 | 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});
512513 }
513514
514515let rec extension_of_error {loc; msg; if_highlight; sub} =
0 commit comments