@@ -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 ;
@@ -307,10 +310,7 @@ module E = struct
307310 variant ~loc ~attrs lab (map_opt (sub.expr sub) eo)
308311 | Pexp_record (l , eo ) ->
309312 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)
314314 (map_opt (sub.expr sub) eo)
315315 | Pexp_field (e , lid ) ->
316316 field ~loc ~attrs (sub.expr sub e) (map_loc sub lid)
@@ -393,12 +393,7 @@ module P = struct
393393 construct ~loc ~attrs (map_loc sub l) (map_opt (sub.pat sub) p)
394394 | Ppat_variant (l , p ) -> variant ~loc ~attrs l (map_opt (sub.pat sub) p)
395395 | 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
402397 | Ppat_array pl -> array ~loc ~attrs (List. map (sub.pat sub) pl)
403398 | Ppat_or (p1 , p2 ) -> or_ ~loc ~attrs (sub.pat sub p1) (sub.pat sub p2)
404399 | Ppat_constraint (p , t ) ->
@@ -511,6 +506,12 @@ let default_mapper =
511506 | PSig x -> PSig (this.signature this x)
512507 | PTyp x -> PTyp (this.typ this x)
513508 | 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});
514515 }
515516
516517let rec extension_of_error {loc; msg; if_highlight; sub} =
0 commit comments