@@ -51,20 +51,30 @@ and copy_expression :
51
51
Ast_502.Parsetree. pexp_loc_stack;
52
52
Ast_502.Parsetree. pexp_attributes;
53
53
} ->
54
+ let loc = copy_location pexp_loc in
54
55
{
55
- Ast_503.Parsetree. pexp_desc = copy_expression_desc pexp_desc;
56
- Ast_503.Parsetree. pexp_loc = copy_location pexp_loc ;
56
+ Ast_503.Parsetree. pexp_desc = copy_expression_desc_with_loc ~loc pexp_desc;
57
+ Ast_503.Parsetree. pexp_loc = loc ;
57
58
Ast_503.Parsetree. pexp_loc_stack = copy_location_stack pexp_loc_stack;
58
59
Ast_503.Parsetree. pexp_attributes = copy_attributes pexp_attributes;
59
60
}
60
61
61
62
and copy_expression_desc :
62
63
Ast_502.Parsetree. expression_desc -> Ast_503.Parsetree. expression_desc =
63
- function
64
+ fun desc -> copy_expression_desc_with_loc ~loc: Location. none desc
65
+
66
+ and copy_expression_desc_with_loc :
67
+ loc :Location. t ->
68
+ Ast_502.Parsetree. expression_desc ->
69
+ Ast_503.Parsetree. expression_desc =
70
+ fun ~loc desc ->
71
+ match desc with
64
72
| Ast_502.Parsetree. Pexp_ident x0 ->
65
73
Ast_503.Parsetree. Pexp_ident (copy_loc copy_Longident_t x0)
66
74
| Ast_502.Parsetree. Pexp_constant x0 ->
67
- Ast_503.Parsetree. Pexp_constant (copy_constant x0)
75
+ let loc = { loc with loc_ghost = true } in
76
+ let constant = { (copy_constant x0) with pconst_loc = loc } in
77
+ Ast_503.Parsetree. Pexp_constant constant
68
78
| Ast_502.Parsetree. Pexp_let (x0 , x1 , x2 ) ->
69
79
Ast_503.Parsetree. Pexp_let
70
80
(copy_rec_flag x0, List. map copy_value_binding x1, copy_expression x2)
@@ -272,24 +282,38 @@ and copy_pattern : Ast_502.Parsetree.pattern -> Ast_503.Parsetree.pattern =
272
282
Ast_502.Parsetree. ppat_loc_stack;
273
283
Ast_502.Parsetree. ppat_attributes;
274
284
} ->
285
+ let loc = copy_location ppat_loc in
275
286
{
276
- Ast_503.Parsetree. ppat_desc = copy_pattern_desc ppat_desc;
277
- Ast_503.Parsetree. ppat_loc = copy_location ppat_loc ;
287
+ Ast_503.Parsetree. ppat_desc = copy_pattern_desc_with_loc ~loc ppat_desc;
288
+ Ast_503.Parsetree. ppat_loc = loc ;
278
289
Ast_503.Parsetree. ppat_loc_stack = copy_location_stack ppat_loc_stack;
279
290
Ast_503.Parsetree. ppat_attributes = copy_attributes ppat_attributes;
280
291
}
281
292
282
293
and copy_pattern_desc :
283
- Ast_502.Parsetree. pattern_desc -> Ast_503.Parsetree. pattern_desc = function
294
+ Ast_502.Parsetree. pattern_desc -> Ast_503.Parsetree. pattern_desc =
295
+ fun desc -> copy_pattern_desc_with_loc ~loc: Location. none desc
296
+
297
+ and copy_pattern_desc_with_loc :
298
+ loc :Location. t ->
299
+ Ast_502.Parsetree. pattern_desc ->
300
+ Ast_503.Parsetree. pattern_desc =
301
+ fun ~loc desc ->
302
+ match desc with
284
303
| Ast_502.Parsetree. Ppat_any -> Ast_503.Parsetree. Ppat_any
285
304
| Ast_502.Parsetree. Ppat_var x0 ->
286
305
Ast_503.Parsetree. Ppat_var (copy_loc (fun x -> x) x0)
287
306
| Ast_502.Parsetree. Ppat_alias (x0 , x1 ) ->
288
307
Ast_503.Parsetree. Ppat_alias (copy_pattern x0, copy_loc (fun x -> x) x1)
289
308
| Ast_502.Parsetree. Ppat_constant x0 ->
290
- Ast_503.Parsetree. Ppat_constant (copy_constant x0)
309
+ let loc = { loc with loc_ghost = true } in
310
+ let constant = { (copy_constant x0) with pconst_loc = loc } in
311
+ Ast_503.Parsetree. Ppat_constant constant
291
312
| Ast_502.Parsetree. Ppat_interval (x0 , x1 ) ->
292
- Ast_503.Parsetree. Ppat_interval (copy_constant x0, copy_constant x1)
313
+ let loc = { loc with loc_ghost = true } in
314
+ let constant0 = { (copy_constant x0) with pconst_loc = loc } in
315
+ let constant1 = { (copy_constant x1) with pconst_loc = loc } in
316
+ Ast_503.Parsetree. Ppat_interval (constant0, constant1)
293
317
| Ast_502.Parsetree. Ppat_tuple x0 ->
294
318
Ast_503.Parsetree. Ppat_tuple (List. map copy_pattern x0)
295
319
| Ast_502.Parsetree. Ppat_construct (x0 , x1 ) ->
0 commit comments