@@ -966,6 +966,7 @@ end = struct
966966 | Pconstraint t -> f t
967967 | Pcoerce (t1 , t2 ) -> Option. exists t1 ~f || f t2
968968 in
969+ let check_package_type ptyp = List. exists ptyp.ppt_cstrs ~f: snd_f in
969970 match ctx with
970971 | Pld (PTyp t1 ) -> assert (typ == t1)
971972 | Pld _ -> assert false
@@ -985,13 +986,15 @@ end = struct
985986 | {prf_desc = Rtag (_ , _ , t1N ); _} -> List. exists t1N ~f
986987 | {prf_desc = Rinherit t1 ; _} -> typ == t1 ) )
987988 | Ptyp_open (_ , t1 ) -> assert (t1 == typ)
988- | Ptyp_package ptyp -> assert (List. exists ptyp.ppt_cstrs ~f: snd_f )
989+ | Ptyp_package ptyp -> assert (check_package_type ptyp)
989990 | Ptyp_object (fields , _ ) ->
990991 assert (
991992 List. exists fields ~f: (function
992993 | {pof_desc = Otag (_ , t1 ); _} -> typ == t1
993994 | {pof_desc = Oinherit t1 ; _} -> typ == t1 ) )
994- | Ptyp_class (_ , l ) -> assert (List. exists l ~f ) )
995+ | Ptyp_class (_ , l ) -> assert (List. exists l ~f )
996+ | Ptyp_functor (_ , _ , ptyp , rhs ) ->
997+ assert (rhs == typ || check_package_type ptyp) )
995998 | Td {ptype_params; ptype_cstrs; ptype_kind; ptype_manifest; _} ->
996999 assert (
9971000 List. exists ptype_params ~f: fst_f
@@ -1018,8 +1021,7 @@ end = struct
10181021 match ctx.ppat_desc with
10191022 | Ppat_constraint (_ , t1 ) -> assert (typ == t1)
10201023 | Ppat_extension (_ , PTyp t ) -> assert (typ == t)
1021- | Ppat_unpack (_ , Some ptyp ) ->
1022- assert (List. exists ptyp.ppt_cstrs ~f: (fun (_ , t ) -> typ == t))
1024+ | Ppat_unpack (_ , Some ptyp ) -> assert (check_package_type ptyp)
10231025 | Ppat_record (l , _ ) ->
10241026 assert (List. exists l ~f: (fun (_ , t , _ ) -> Option. exists t ~f ))
10251027 | Ppat_tuple (l , _ ) ->
@@ -1030,8 +1032,7 @@ end = struct
10301032 | _ -> assert false )
10311033 | Exp ctx -> (
10321034 match ctx.pexp_desc with
1033- | Pexp_pack (_ , Some ptyp , _ ) ->
1034- assert (List. exists ptyp.ppt_cstrs ~f: snd_f)
1035+ | Pexp_pack (_ , Some ptyp , _ ) -> assert (check_package_type ptyp)
10351036 | Pexp_constraint (_, t1)
10361037 | Pexp_coerce (_, None , t1)
10371038 | Pexp_extension (_ , PTyp t1 ) ->
@@ -1079,8 +1080,9 @@ end = struct
10791080 | Mod ctx -> (
10801081 match ctx.pmod_desc with
10811082 | Pmod_unpack (_ , ty1 , ty2 ) ->
1082- let f ptyp = List. exists ptyp.ppt_cstrs ~f: snd_f in
1083- assert (Option. exists ty1 ~f || Option. exists ty2 ~f )
1083+ assert (
1084+ Option. exists ty1 ~f: check_package_type
1085+ || Option. exists ty2 ~f: check_package_type )
10841086 | _ -> assert false )
10851087 | Sig ctx -> (
10861088 match ctx.psig_desc with
@@ -1583,16 +1585,18 @@ end = struct
15831585 | _ -> false
15841586 in
15851587 let constructor_cxt_prec_of_inner = function
1586- | {ptyp_desc = Ptyp_arrow _ | Ptyp_poly _ ; _} -> Some (Apply , Non )
1588+ | {ptyp_desc = Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _ ; _} ->
1589+ Some (Apply , Non )
15871590 | {ptyp_desc = Ptyp_tuple _ ; _} -> Some (InfixOp3 , Non )
15881591 | _ -> None
15891592 in
15901593 match ctx with
15911594 | { ctx= Td {ptype_kind= Ptype_variant v; _}
15921595 ; ast=
15931596 Typ
1594- ({ptyp_desc= Ptyp_arrow _ | Ptyp_poly _ | Ptyp_tuple _; _} as typ)
1595- }
1597+ ( { ptyp_desc=
1598+ Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _ | Ptyp_tuple _
1599+ ; _ } as typ ) }
15961600 when List. exists v ~f: (is_tuple_lvl1_in_constructor typ) ->
15971601 constructor_cxt_prec_of_inner typ
15981602 | { ctx=
@@ -1601,7 +1605,9 @@ end = struct
16011605 | Sig {psig_desc= Psig_typext {ptyext_constructors= l; _}; _} )
16021606 ; ast=
16031607 Typ
1604- ({ptyp_desc= Ptyp_arrow _ | Ptyp_poly _ | Ptyp_tuple _; _} as typ)
1608+ ( { ptyp_desc=
1609+ Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _ | Ptyp_tuple _
1610+ ; _ } as typ )
16051611 ; _ }
16061612 when List. exists l ~f: (is_tuple_lvl1_in_ext_constructor typ) ->
16071613 constructor_cxt_prec_of_inner typ
@@ -1621,8 +1627,9 @@ end = struct
16211627 ; _ } )
16221628 ; ast=
16231629 Typ
1624- ({ptyp_desc= Ptyp_tuple _ | Ptyp_arrow _ | Ptyp_poly _; _} as typ)
1625- }
1630+ ( { ptyp_desc=
1631+ Ptyp_tuple _ | Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _
1632+ ; _ } as typ ) }
16261633 when is_tuple_lvl1_in_ext_constructor typ constr ->
16271634 constructor_cxt_prec_of_inner typ
16281635 | {ctx = Str _ | Str_exp _ ; ast = Typ _ ; _} -> None
@@ -1634,7 +1641,7 @@ end = struct
16341641 else Right
16351642 in
16361643 Some (MinusGreater , assoc)
1637- | Ptyp_poly _ -> Some (MinusGreater , Right )
1644+ | Ptyp_poly _ | Ptyp_functor _ -> Some (MinusGreater , Right )
16381645 | Ptyp_tuple _ -> Some (InfixOp3 , Non )
16391646 | Ptyp_alias _ -> Some (As , Non )
16401647 | Ptyp_constr (_ , _ :: _ :: _ ) -> Some (Comma , Non )
@@ -1770,7 +1777,7 @@ end = struct
17701777 | Typ {ptyp_desc; _} -> (
17711778 match ptyp_desc with
17721779 | Ptyp_package _ -> Some Low
1773- | Ptyp_arrow _ | Ptyp_poly _ -> Some MinusGreater
1780+ | Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _ -> Some MinusGreater
17741781 | Ptyp_tuple _ -> Some InfixOp3
17751782 | Ptyp_alias _ -> Some As
17761783 | Ptyp_any | Ptyp_var _ | Ptyp_constr _ | Ptyp_object _
@@ -1869,7 +1876,10 @@ end = struct
18691876 match xtyp with
18701877 | {ast = {ptyp_desc = Ptyp_package _ ; _} ; _} -> true
18711878 | {ast = {ptyp_desc = Ptyp_alias _ ; _} ; ctx = Typ _ } -> true
1872- | { ast= {ptyp_desc= Ptyp_arrow _ | Ptyp_poly _ | Ptyp_tuple _; _}
1879+ | { ast=
1880+ { ptyp_desc=
1881+ Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _ | Ptyp_tuple _
1882+ ; _ }
18731883 ; ctx= Typ {ptyp_desc= Ptyp_class _; _} } ->
18741884 true
18751885 | { ast= {ptyp_desc= Ptyp_alias _; _}
@@ -1887,15 +1897,17 @@ end = struct
18871897 true
18881898 | { ast=
18891899 { ptyp_desc=
1890- Ptyp_alias _ | Ptyp_arrow _ | Ptyp_poly _ | Ptyp_tuple _
1900+ ( Ptyp_alias _ | Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _
1901+ | Ptyp_tuple _ )
18911902 ; _ }
18921903 ; ctx=
18931904 ( Str {pstr_desc= Pstr_exception _; _}
18941905 | Str_exp {pstr_desc= Pstr_exception _; _}
18951906 | Sig {psig_desc = Psig_exception _ ; _} ) } ->
18961907 true
18971908 | { ast= {ptyp_desc= Ptyp_tuple ({lte_label= Some _; _} :: _); _}
1898- ; ctx= Typ {ptyp_desc= Ptyp_arrow _ | Ptyp_poly _ ; _ } } ->
1909+ ; ctx= Typ {ptyp_desc= Ptyp_arrow _ | Ptyp_poly _ | Ptyp_functor _; _}
1910+ } ->
18991911 true
19001912 | _ -> (
19011913 match ambig_prec (sub_ast ~ctx (Typ typ)) with
0 commit comments