@@ -86,13 +86,11 @@ let location_of_attrib t name (attribs:attributes) =
8686 let prefix = module_name t.driver in
8787 let has_name s = String. equal s name || String. equal s (sprintf " %s.%s" prefix name) in
8888 List. find_map_exn
89- ~f: (function ( { loc = _ ; txt} , Parsetree. PStr [{pstr_loc; _} ]) when has_name txt -> Some pstr_loc
89+ ~f: (function { attr_name = { txt; _} ; attr_payload = Parsetree. PStr [{pstr_loc; _}]; _} when has_name txt -> Some pstr_loc
9090 | _ -> None
9191 ) attribs
9292
93- let row_loc = function
94- | Rtag (sloc , _ , _ , _ ) -> sloc.loc
95- | Rinherit typ -> typ.ptyp_loc
93+ let row_loc row = row.prf_loc
9694
9795let get_variant_name t row =
9896 match Attribute. get t.variant_name row, Attribute. get t.variant_key row with
@@ -132,9 +130,9 @@ let test_constructor_mapping t constrs =
132130
133131let test_row_mapping t rows =
134132 let base, mapped = List. partition_map ~f: (fun row ->
135- let (row_name, attrs) = match row with
133+ let (row_name, attrs) = match row.prf_desc with
136134 | Rinherit _ -> raise_errorf " Inherited polymorphic variant types not supported"
137- | Rtag (name , attrs , _ , _ ) -> name, attrs
135+ | Rtag (name , _ , _ ) -> name, row.prf_attributes
138136 in
139137 match get_variant_name t row with
140138 | Some name when String. equal row_name.txt name -> `Fst name
@@ -248,7 +246,7 @@ and serialize_variant t ~loc type_ ~name ~alias pcstr =
248246 let f_name = { loc; txt = sprintf " _%s_of_record_" name } in
249247 let lhs = ppat_constr ~loc name (Some patt) in
250248 let rhs = pexp_apply ~loc (pexp_ident_string_loc f_name) [Nolabel , pexp_tuple ~loc (List. map ~f: snd args)] in
251- let binding = value_binding ~loc ~pat: {ppat_desc = Ppat_var f_name; ppat_loc = loc; ppat_attributes= [] } ~expr: f in
249+ let binding = value_binding ~loc ~pat: {ppat_desc = Ppat_var f_name; ppat_loc = loc; ppat_attributes= [] ; ppat_loc_stack = [] } ~expr: f in
252250 binding, case ~lhs ~guard: None ~rhs
253251 | Pcstr_tuple core_types ->
254252 let f_name = { loc; txt = sprintf " _%s_of_tuple" name } in
@@ -261,7 +259,7 @@ and serialize_variant t ~loc type_ ~name ~alias pcstr =
261259 [% e estring ~loc alias] Protocol_conv.Runtime.Tuple_out. ([% e spec])
262260 ]
263261 in
264- let binding = value_binding ~loc ~pat: {ppat_desc = Ppat_var f_name; ppat_loc = loc; ppat_attributes= [] } ~expr: f in
262+ let binding = value_binding ~loc ~pat: {ppat_desc = Ppat_var f_name; ppat_loc = loc; ppat_attributes= [] ; ppat_loc_stack = [] } ~expr: f in
265263
266264 let lhs = ppat_constr ~loc name (mk_pattern core_types) in
267265 let args =
@@ -331,9 +329,9 @@ and serialize_expr_of_type_descr t ~loc = function
331329 | Ptyp_variant (rows , _closed , None) ->
332330 test_row_mapping t rows;
333331 let bindings, cases =
334- List. map ~f: (function
332+ List. map ~f: (fun row -> match row.prf_desc with
335333 | Rinherit _ -> raise_errorf ~loc " Inherited types not supported"
336- | Rtag (name , _attributes , _bool , core_types ) as row ->
334+ | Rtag (name , _bool , core_types ) ->
337335 let alias = match get_variant_name t row with
338336 | Some key -> key
339337 | None -> name.txt
@@ -510,9 +508,9 @@ and deserialize_expr_of_type_descr t ~loc = function
510508
511509 | Ptyp_variant (rows , _closed , None) ->
512510 test_row_mapping t rows;
513- let mk_elem = function
511+ let mk_elem row = match row.prf_desc with
514512 | Rinherit _ -> raise_errorf ~loc " Inherited variant types not supported"
515- | Rtag (name , _attributes , _bool , core_types ) as row ->
513+ | Rtag (name , _bool , core_types ) ->
516514 let ser_name = match get_variant_name t row with
517515 | Some key -> key
518516 | None -> name.txt
@@ -602,8 +600,8 @@ let rec is_recursive_ct types = function
602600 | { ptyp_desc = Ptyp_class _ ; _} -> false
603601 | { ptyp_desc = Ptyp_alias (c , _ ); _} -> is_recursive_ct types c
604602 | { ptyp_desc = Ptyp_variant (rows , _ , _ ); _} ->
605- List. exists ~f: (function
606- | Rtag (_ , _ , _ , cts ) -> List. exists ~f: (is_recursive_ct types) cts
603+ List. exists ~f: (fun row -> match row.prf_desc with
604+ | Rtag (_ , _ , cts ) -> List. exists ~f: (is_recursive_ct types) cts
607605 | Rinherit _ -> false
608606 ) rows
609607 | { ptyp_desc = Ptyp_poly (_ , ct ); _} -> is_recursive_ct types ct
0 commit comments