@@ -312,7 +312,7 @@ class virtual ['res] lift2 =
312312 self#constr " Ptyp_class" [ " longident_loc" , a; " core_type list" , b ]
313313 | Ptyp_alias (a , b ), Ptyp_alias (a' , b' ) ->
314314 let a = self#core_type a a' in
315- let b = self#string b b' in
315+ let b = self#loc self# string b b' in
316316 self#constr " Ptyp_alias" [ " core_type" , a; " label" , b ]
317317 | Ptyp_variant (a , b , c ), Ptyp_variant (a' , b' , c' ) ->
318318 let a = self#list self#row_field a a' in
@@ -331,6 +331,10 @@ class virtual ['res] lift2 =
331331 | Ptyp_extension a , Ptyp_extension a' ->
332332 let a = self#extension a a' in
333333 self#constr " Ptyp_extension" [ " extension" , a ]
334+ | Ptyp_open (a , b ), Ptyp_open (a' , b' ) ->
335+ let a = self#longident_loc a a' in
336+ let b = self#core_type b b' in
337+ self#constr " Ptyp_open" [ " longident_loc" , a; " core_type" , b ]
334338 | _ -> Error " core_type_desc"
335339
336340 method package_type : package_type -> package_type -> ('res, string ) result =
@@ -532,17 +536,13 @@ class virtual ['res] lift2 =
532536 self#constr
533537 " Pexp_let"
534538 [ " rec_flag" , a; " value_binding list" , b; " expression" , c ]
535- | Pexp_function a , Pexp_function a' ->
536- let a = self#cases a a' in
537- self#constr " Pexp_function" [ " cases" , a ]
538- | Pexp_fun (a , b , c , d ), Pexp_fun (a' , b' , c' , d' ) ->
539- let a = self#arg_label a a' in
540- let b = self#option self#expression b b' in
541- let c = self#pattern c c' in
542- let d = self#expression d d' in
539+ | Pexp_function (a , b , c ), Pexp_function (a' , b' , c' ) ->
540+ let a = self#list self#function_param a a' in
541+ let b = self#option self#type_constraint b b' in
542+ let c = self#function_body c c' in
543543 self#constr
544- " Pexp_fun "
545- [ " arg_label " , a; " expression option" , b; " pattern " , c; " expression " , d ]
544+ " Pexp_function "
545+ [ " function_param list " , a; " type_constraint option" , b; " function_body " , c ]
546546 | Pexp_apply (a , b ), Pexp_apply (a' , b' ) ->
547547 let a = self#expression a a' in
548548 let b =
@@ -741,37 +741,34 @@ class virtual ['res] lift2 =
741741 self#constr
742742 " Pexp_let"
743743 [ " rec_flag" , a; " value_binding list" , b; " expression" , c ]
744- (* Caused by: [fun (t39 : t39 Js_of_ocaml.Js.t) -> ...] *)
745- | ( Pexp_fun (a, b, c, d)
746- , Pexp_apply ({ pexp_desc = Pexp_fun (a', b', c', d'); _ }, _) ) ->
747- let a = self#arg_label a a' in
748- let b = self#option self#expression b b' in
749- let c = self#pattern c c' in
750- let d = self#expression d d' in
744+ (* Caused by: [function param -> ...] when wrapped in Pexp_apply *)
745+ | ( Pexp_function ((_ :: _ as a), b, c)
746+ , Pexp_apply ({ pexp_desc = Pexp_function ((_ :: _ as a'), b', c'); _ }, _) ) ->
747+ let a = self#list self#function_param a a' in
748+ let b = self#option self#type_constraint b b' in
749+ let c = self#function_body c c' in
751750 self#constr
752- " Pexp_fun "
753- [ " arg_label " , a; " expression option" , b; " pattern " , c; " expression " , d ]
754- (* Caused by: [fun x -> Ppx_deriving_runtime.Format.asprintf "%a" pp x] *)
755- | ( Pexp_fun (a , b, c, d )
756- , Pexp_constraint ({ pexp_desc = Pexp_fun (a' , b', c', d' ); _ }, _) ) ->
757- let a = self#arg_label a a' in
758- let b = self#option self#expression b b ' in
759- let c = self#pattern c c ' in
760- let d = self#expression d d ' in
751+ " Pexp_function "
752+ [ " function_param list " , a; " type_constraint option" , b; " function_body " , c ]
753+ (* Caused by: [function param -> ...] when wrapped in Pexp_constraint *)
754+ | ( Pexp_function ((_ :: _ as a) , b, c)
755+ , Pexp_constraint ({ pexp_desc = Pexp_function ((_ :: _ as a') , b', c'); _ }, _)
756+ ) ->
757+ let a = self#list self#function_param a a ' in
758+ let b = self#option self#type_constraint b b ' in
759+ let c = self#function_body c c ' in
761760 self#constr
762- " Pexp_fun"
763- [ " arg_label" , a; " expression option" , b; " pattern" , c; " expression" , d ]
764- (* Caused by: {[ fun env -> fun _visitors_this_0 -> fun _visitors_this_1
765- -> ]} in opams package morbig/src/CST for instance *)
766- | ( Pexp_fun (a, b, c, d)
767- , Pexp_poly ({ pexp_desc = Pexp_fun (a', b', c', d'); _ }, _) ) ->
768- let a = self#arg_label a a' in
769- let b = self#option self#expression b b' in
770- let c = self#pattern c c' in
771- let d = self#expression d d' in
761+ " Pexp_function"
762+ [ " function_param list" , a; " type_constraint option" , b; " function_body" , c ]
763+ (* Caused by: [function param -> ...] when wrapped in Pexp_poly *)
764+ | ( Pexp_function ((_ :: _ as a), b, c)
765+ , Pexp_poly ({ pexp_desc = Pexp_function ((_ :: _ as a'), b', c'); _ }, _) ) ->
766+ let a = self#list self#function_param a a' in
767+ let b = self#option self#type_constraint b b' in
768+ let c = self#function_body c c' in
772769 self#constr
773- " Pexp_fun "
774- [ " arg_label " , a; " expression option" , b; " pattern " , c; " expression " , d ]
770+ " Pexp_function "
771+ [ " function_param list " , a; " type_constraint option" , b; " function_body " , c ]
775772 (* Caused by this recurent piece of code: {[ ((fun (type res) -> fun
776773 (type t9) -> fun (type t8) -> fun (t9 : t9 Js_of_ocaml.Js.t) -> fun
777774 (t8 : t8) -> fun (_ : t9 -> < set: t8 -> unit ;.. >
@@ -1748,6 +1745,9 @@ class virtual ['res] lift2 =
17481745 | Pmod_extension a , Pmod_extension a' ->
17491746 let a = self#extension a a' in
17501747 self#constr " Pmod_extension" [ " extension" , a ]
1748+ | Pmod_apply_unit a , Pmod_apply_unit a' ->
1749+ let a = self#module_expr a a' in
1750+ self#constr " Pmod_apply_unit" [ " module_expr" , a ]
17511751 | _ -> Error " module_expr_desc"
17521752
17531753 method structure : structure -> structure -> ('res, string ) result =
@@ -1815,22 +1815,27 @@ class virtual ['res] lift2 =
18151815 | _ -> Error " structure_item_desc"
18161816
18171817 method value_binding : value_binding -> value_binding -> ('res, string ) result =
1818- fun { pvb_pat; pvb_expr; pvb_attributes; pvb_loc }
1818+ fun { pvb_pat; pvb_expr; pvb_attributes; pvb_loc; pvb_constraint }
18191819 { pvb_pat = pvb_pat'
18201820 ; pvb_expr = pvb_expr'
18211821 ; pvb_attributes = pvb_attributes'
18221822 ; pvb_loc = pvb_loc'
1823+ ; pvb_constraint = pvb_constraint'
18231824 } ->
18241825 let pvb_pat = self#pattern pvb_pat pvb_pat' in
18251826 let pvb_expr = self#expression pvb_expr pvb_expr' in
18261827 let pvb_attributes = self#attributes pvb_attributes pvb_attributes' in
18271828 let pvb_loc = self#location pvb_loc pvb_loc' in
1829+ let pvb_constraint =
1830+ self#option self#value_constraint pvb_constraint pvb_constraint'
1831+ in
18281832 self#record
18291833 " value_binding"
18301834 [ " pvb_pat" , pvb_pat
18311835 ; " pvb_expr" , pvb_expr
18321836 ; " pvb_attributes" , pvb_attributes
18331837 ; " pvb_loc" , pvb_loc
1838+ ; " pvb_constraint" , pvb_constraint
18341839 ]
18351840
18361841 method module_binding : module_binding -> module_binding -> ('res, string ) result =
@@ -1904,4 +1909,78 @@ class virtual ['res] lift2 =
19041909 | _ -> Error " directive_argument_desc"
19051910
19061911 method cases : cases -> cases -> ('res, string ) result = self#list self#case
1912+
1913+ method function_param : function_param -> function_param -> ('res, string ) result =
1914+ fun { pparam_loc; pparam_desc }
1915+ { pparam_loc = pparam_loc' ; pparam_desc = pparam_desc' } ->
1916+ let pparam_loc = self#location pparam_loc pparam_loc' in
1917+ let pparam_desc = self#function_param_desc pparam_desc pparam_desc' in
1918+ self#record
1919+ " function_param"
1920+ [ " pparam_loc" , pparam_loc; " pparam_desc" , pparam_desc ]
1921+
1922+ method function_param_desc
1923+ : function_param_desc -> function_param_desc -> ('res, string ) result =
1924+ fun x x' ->
1925+ match x, x' with
1926+ | Pparam_val (a , b , c ), Pparam_val (a' , b' , c' ) ->
1927+ let a = self#arg_label a a' in
1928+ let b = self#option self#expression b b' in
1929+ let c = self#pattern c c' in
1930+ self#constr
1931+ " Pparam_val"
1932+ [ " arg_label" , a; " expression option" , b; " pattern" , c ]
1933+ | Pparam_newtype a , Pparam_newtype a' ->
1934+ let a = self#loc self#string a a' in
1935+ self#constr " Pparam_newtype" [ " string loc" , a ]
1936+ | _ -> Error " function_param_desc"
1937+
1938+ method type_constraint : type_constraint -> type_constraint -> ('res, string ) result =
1939+ fun x x' ->
1940+ match x, x' with
1941+ | Pconstraint a , Pconstraint a' ->
1942+ let a = self#core_type a a' in
1943+ self#constr " Pconstraint" [ " core_type" , a ]
1944+ | Pcoerce (a , b ), Pcoerce (a' , b' ) ->
1945+ let a = self#option self#core_type a a' in
1946+ let b = self#core_type b b' in
1947+ self#constr " Pcoerce" [ " core_type option" , a; " core_type" , b ]
1948+ | _ -> Error " type_constraint"
1949+
1950+ method value_constraint
1951+ : value_constraint -> value_constraint -> ('res, string ) result =
1952+ fun x x' ->
1953+ match x, x' with
1954+ | ( Pvc_constraint { locally_abstract_univars; typ }
1955+ , Pvc_constraint
1956+ { locally_abstract_univars = locally_abstract_univars'; typ = typ' } ) ->
1957+ let locally_abstract_univars =
1958+ self#list
1959+ (self#loc self#string)
1960+ locally_abstract_univars
1961+ locally_abstract_univars'
1962+ in
1963+ let typ = self#core_type typ typ' in
1964+ self#constr
1965+ " Pvc_constraint"
1966+ [ " locally_abstract_univars" , locally_abstract_univars; " typ" , typ ]
1967+ | ( Pvc_coercion { ground; coercion }
1968+ , Pvc_coercion { ground = ground'; coercion = coercion' } ) ->
1969+ let ground = self#option self#core_type ground ground' in
1970+ let coercion = self#core_type coercion coercion' in
1971+ self#constr " Pvc_coercion" [ " ground" , ground; " coercion" , coercion ]
1972+ | _ -> Error " value_constraint"
1973+
1974+ method function_body : function_body -> function_body -> ('res, string ) result =
1975+ fun x x' ->
1976+ match x, x' with
1977+ | Pfunction_body a , Pfunction_body a' ->
1978+ let a = self#expression a a' in
1979+ self#constr " Pfunction_body" [ " expression" , a ]
1980+ | Pfunction_cases (a , b , c ), Pfunction_cases (a' , b' , c' ) ->
1981+ let a = self#cases a a' in
1982+ let b = self#location b b' in
1983+ let c = self#attributes c c' in
1984+ self#constr " Pfunction_cases" [ " cases" , a; " location" , b; " attributes" , c ]
1985+ | _ -> Error " function_body"
19071986 end
0 commit comments