1995-08-09 08:06:35 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1995-08-09 08:06:35 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2002-04-18 00:27:47 -07:00
|
|
|
(* typetexp.ml,v 1.34.4.9 2002/01/07 08:39:16 garrigue Exp *)
|
1995-08-09 08:06:35 -07:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Typechecking of type expressions for the core language *)
|
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
open Misc
|
1995-05-04 03:15:53 -07:00
|
|
|
open Parsetree
|
1996-09-23 04:33:27 -07:00
|
|
|
open Types
|
1995-05-04 03:15:53 -07:00
|
|
|
open Ctype
|
|
|
|
|
|
|
|
exception Already_bound
|
|
|
|
|
|
|
|
type error =
|
|
|
|
Unbound_type_variable of string
|
|
|
|
| Unbound_type_constructor of Longident.t
|
2001-11-27 18:14:39 -08:00
|
|
|
| Unbound_type_constructor_2 of Path.t
|
1995-05-04 03:15:53 -07:00
|
|
|
| Type_arity_mismatch of Longident.t * int * int
|
1996-04-22 04:15:41 -07:00
|
|
|
| Bound_type_variable of string
|
|
|
|
| Recursive_type
|
|
|
|
| Unbound_row_variable of Longident.t
|
1997-02-20 12:39:02 -08:00
|
|
|
| Type_mismatch of (type_expr * type_expr) list
|
|
|
|
| Alias_type_mismatch of (type_expr * type_expr) list
|
1999-11-30 08:07:38 -08:00
|
|
|
| Present_has_conjunction of string
|
|
|
|
| Present_has_no_type of string
|
2001-09-25 02:54:18 -07:00
|
|
|
| Constructor_mismatch of type_expr * type_expr
|
|
|
|
| Not_a_variant of type_expr
|
2002-01-03 18:02:50 -08:00
|
|
|
| Variant_tags of string * string
|
2003-03-07 00:59:15 -08:00
|
|
|
| Invalid_variable_name of string
|
2003-05-19 02:21:17 -07:00
|
|
|
| Cannot_quantify of string * type_expr
|
2009-10-26 03:53:16 -07:00
|
|
|
| Multiple_constraints_on_type of string
|
2010-01-20 08:26:46 -08:00
|
|
|
| Repeated_method_label of string
|
2010-05-18 09:46:46 -07:00
|
|
|
| Unbound_value of Longident.t
|
|
|
|
| Unbound_constructor of Longident.t
|
|
|
|
| Unbound_label of Longident.t
|
|
|
|
| Unbound_module of Longident.t
|
|
|
|
| Unbound_class of Longident.t
|
2010-05-18 10:18:24 -07:00
|
|
|
| Unbound_modtype of Longident.t
|
2010-05-18 10:25:02 -07:00
|
|
|
| Unbound_cltype of Longident.t
|
2010-05-18 09:46:46 -07:00
|
|
|
| Ill_typed_functor_application of Longident.t
|
1995-05-04 03:15:53 -07:00
|
|
|
|
|
|
|
exception Error of Location.t * error
|
|
|
|
|
2002-08-04 22:58:08 -07:00
|
|
|
type variable_context = int * (string, type_expr) Tbl.t
|
|
|
|
|
2011-11-24 01:02:48 -08:00
|
|
|
(* Local definitions *)
|
|
|
|
|
|
|
|
let instance_list = Ctype.instance_list Env.empty
|
|
|
|
|
2010-05-18 09:46:46 -07:00
|
|
|
(* Narrowing unbound identifier errors. *)
|
|
|
|
|
|
|
|
let rec narrow_unbound_lid_error env loc lid make_error =
|
|
|
|
let check_module mlid =
|
|
|
|
try ignore (Env.lookup_module mlid env)
|
2011-09-22 02:05:42 -07:00
|
|
|
with Not_found ->
|
|
|
|
narrow_unbound_lid_error env loc mlid (fun lid -> Unbound_module lid);
|
|
|
|
assert false
|
2010-05-18 09:46:46 -07:00
|
|
|
in
|
|
|
|
begin match lid with
|
|
|
|
| Longident.Lident _ -> ()
|
|
|
|
| Longident.Ldot (mlid, _) -> check_module mlid
|
|
|
|
| Longident.Lapply (flid, mlid) ->
|
|
|
|
check_module flid;
|
|
|
|
check_module mlid;
|
|
|
|
raise (Error (loc, Ill_typed_functor_application lid))
|
|
|
|
end;
|
|
|
|
raise (Error (loc, make_error lid))
|
|
|
|
|
|
|
|
let find_component lookup make_error env loc lid =
|
|
|
|
try
|
|
|
|
match lid with
|
2011-09-22 02:05:42 -07:00
|
|
|
| Longident.Ldot (Longident.Lident "*predef*", s) ->
|
|
|
|
lookup (Longident.Lident s) Env.initial
|
2010-05-18 09:46:46 -07:00
|
|
|
| _ -> lookup lid env
|
|
|
|
with Not_found ->
|
2010-08-02 07:37:22 -07:00
|
|
|
(narrow_unbound_lid_error env loc lid make_error
|
|
|
|
: unit (* to avoid a warning *));
|
2010-05-18 09:46:46 -07:00
|
|
|
assert false
|
|
|
|
|
2011-09-22 02:05:42 -07:00
|
|
|
let find_type =
|
|
|
|
find_component Env.lookup_type (fun lid -> Unbound_type_constructor lid)
|
|
|
|
let find_constructor =
|
|
|
|
find_component Env.lookup_constructor (fun lid -> Unbound_constructor lid)
|
|
|
|
let find_label =
|
|
|
|
find_component Env.lookup_label (fun lid -> Unbound_label lid)
|
|
|
|
let find_class =
|
|
|
|
find_component Env.lookup_class (fun lid -> Unbound_class lid)
|
|
|
|
let find_value =
|
|
|
|
find_component Env.lookup_value (fun lid -> Unbound_value lid)
|
|
|
|
let find_module =
|
|
|
|
find_component Env.lookup_module (fun lid -> Unbound_module lid)
|
|
|
|
let find_modtype =
|
|
|
|
find_component Env.lookup_modtype (fun lid -> Unbound_modtype lid)
|
|
|
|
let find_cltype =
|
|
|
|
find_component Env.lookup_cltype (fun lid -> Unbound_cltype lid)
|
2010-05-18 10:25:02 -07:00
|
|
|
|
2009-10-26 03:53:16 -07:00
|
|
|
(* Support for first-class modules. *)
|
|
|
|
|
|
|
|
let transl_modtype_longident = ref (fun _ -> assert false)
|
|
|
|
let transl_modtype = ref (fun _ -> assert false)
|
|
|
|
|
|
|
|
let create_package_mty fake loc env (p, l) =
|
|
|
|
let l =
|
|
|
|
List.sort
|
|
|
|
(fun (s1, t1) (s2, t2) ->
|
|
|
|
if s1 = s2 then raise (Error (loc, Multiple_constraints_on_type s1));
|
|
|
|
compare s1 s2)
|
|
|
|
l
|
|
|
|
in
|
|
|
|
l,
|
|
|
|
List.fold_left
|
|
|
|
(fun mty (s, t) ->
|
|
|
|
let d = {ptype_params = [];
|
|
|
|
ptype_cstrs = [];
|
|
|
|
ptype_kind = Ptype_abstract;
|
|
|
|
ptype_private = Asttypes.Public;
|
|
|
|
ptype_manifest = if fake then None else Some t;
|
|
|
|
ptype_variance = [];
|
|
|
|
ptype_loc = loc} in
|
2011-09-22 02:05:42 -07:00
|
|
|
{pmty_desc=Pmty_with (mty, [ Longident.Lident s, Pwith_type d ]);
|
|
|
|
pmty_loc=loc}
|
2009-10-26 03:53:16 -07:00
|
|
|
)
|
|
|
|
{pmty_desc=Pmty_ident p; pmty_loc=loc}
|
|
|
|
l
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Translation of type expressions *)
|
|
|
|
|
|
|
|
let type_variables = ref (Tbl.empty : (string, type_expr) Tbl.t)
|
2003-05-19 02:21:17 -07:00
|
|
|
let univars = ref ([] : (string * type_expr) list)
|
2002-04-18 00:27:47 -07:00
|
|
|
let pre_univars = ref ([] : type_expr list)
|
2005-07-21 21:11:47 -07:00
|
|
|
let used_variables = ref (Tbl.empty : (string, type_expr * Location.t) Tbl.t)
|
2003-03-19 23:36:55 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
let reset_type_variables () =
|
1996-04-22 04:15:41 -07:00
|
|
|
reset_global_level ();
|
2002-08-04 22:58:08 -07:00
|
|
|
type_variables := Tbl.empty
|
1998-06-24 12:22:26 -07:00
|
|
|
|
|
|
|
let narrow () =
|
2002-08-04 22:58:08 -07:00
|
|
|
(increase_global_level (), !type_variables)
|
|
|
|
|
|
|
|
let widen (gl, tv) =
|
|
|
|
restore_global_level gl;
|
|
|
|
type_variables := tv
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2011-09-22 02:05:42 -07:00
|
|
|
let strict_lowercase c = (c = '_' || c >= 'a' && c <= 'z')
|
|
|
|
|
|
|
|
let validate_name = function
|
|
|
|
None -> None
|
|
|
|
| Some name as s ->
|
|
|
|
if name <> "" && strict_lowercase name.[0] then s else None
|
|
|
|
|
|
|
|
let new_global_var ?name () =
|
|
|
|
new_global_var ?name:(validate_name name) ()
|
|
|
|
let newvar ?name () =
|
|
|
|
newvar ?name:(validate_name name) ()
|
|
|
|
|
2003-03-07 00:59:15 -08:00
|
|
|
let enter_type_variable strict loc name =
|
1995-05-04 03:15:53 -07:00
|
|
|
try
|
2003-03-07 00:59:15 -08:00
|
|
|
if name <> "" && name.[0] = '_' then
|
|
|
|
raise (Error (loc, Invalid_variable_name ("'" ^ name)));
|
1996-05-26 06:42:34 -07:00
|
|
|
let v = Tbl.find name !type_variables in
|
|
|
|
if strict then raise Already_bound;
|
|
|
|
v
|
1995-05-04 03:15:53 -07:00
|
|
|
with Not_found ->
|
2011-09-22 02:05:42 -07:00
|
|
|
let v = new_global_var ~name () in
|
1995-05-04 03:15:53 -07:00
|
|
|
type_variables := Tbl.add name v !type_variables;
|
|
|
|
v
|
|
|
|
|
1996-04-22 04:15:41 -07:00
|
|
|
let type_variable loc name =
|
|
|
|
try
|
|
|
|
Tbl.find name !type_variables
|
|
|
|
with Not_found ->
|
1998-08-31 12:41:24 -07:00
|
|
|
raise(Error(loc, Unbound_type_variable ("'" ^ name)))
|
1996-04-22 04:15:41 -07:00
|
|
|
|
2002-04-18 00:27:47 -07:00
|
|
|
let wrap_method ty =
|
|
|
|
match (Ctype.repr ty).desc with
|
|
|
|
Tpoly _ -> ty
|
|
|
|
| _ -> Ctype.newty (Tpoly (ty, []))
|
1996-04-22 04:15:41 -07:00
|
|
|
|
2011-09-22 02:05:42 -07:00
|
|
|
let new_pre_univar ?name () =
|
|
|
|
let v = newvar ?name () in pre_univars := v :: !pre_univars; v
|
2002-04-18 00:27:47 -07:00
|
|
|
|
|
|
|
let rec swap_list = function
|
|
|
|
x :: y :: l -> y :: x :: swap_list l
|
|
|
|
| l -> l
|
|
|
|
|
2005-07-21 21:11:47 -07:00
|
|
|
type policy = Fixed | Extensible | Univars
|
2002-04-18 00:27:47 -07:00
|
|
|
|
2003-05-19 02:21:17 -07:00
|
|
|
let rec transl_type env policy styp =
|
1995-05-04 03:15:53 -07:00
|
|
|
match styp.ptyp_desc with
|
2002-04-18 00:27:47 -07:00
|
|
|
Ptyp_any ->
|
2006-04-17 17:28:12 -07:00
|
|
|
if policy = Univars then new_pre_univar () else
|
|
|
|
if policy = Fixed then
|
|
|
|
raise (Error (styp.ptyp_loc, Unbound_type_variable "_"))
|
|
|
|
else newvar ()
|
1997-02-11 10:24:47 -08:00
|
|
|
| Ptyp_var name ->
|
2003-03-07 00:59:15 -08:00
|
|
|
if name <> "" && name.[0] = '_' then
|
|
|
|
raise (Error (styp.ptyp_loc, Invalid_variable_name ("'" ^ name)));
|
2002-04-18 00:27:47 -07:00
|
|
|
begin try
|
2011-11-24 01:02:48 -08:00
|
|
|
instance env (List.assoc name !univars)
|
2005-07-21 21:11:47 -07:00
|
|
|
with Not_found -> try
|
2011-11-24 01:02:48 -08:00
|
|
|
instance env (fst(Tbl.find name !used_variables))
|
2002-04-18 00:27:47 -07:00
|
|
|
with Not_found ->
|
2005-07-21 21:11:47 -07:00
|
|
|
let v =
|
2011-09-22 02:05:42 -07:00
|
|
|
if policy = Univars then new_pre_univar ~name () else newvar ~name ()
|
|
|
|
in
|
2005-07-21 21:11:47 -07:00
|
|
|
used_variables := Tbl.add name (v, styp.ptyp_loc) !used_variables;
|
|
|
|
v
|
1995-05-04 03:15:53 -07:00
|
|
|
end
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_arrow(l, st1, st2) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty1 = transl_type env policy st1 in
|
|
|
|
let ty2 = transl_type env policy st2 in
|
2001-04-19 01:34:21 -07:00
|
|
|
newty (Tarrow(l, ty1, ty2, Cok))
|
1995-05-04 03:15:53 -07:00
|
|
|
| Ptyp_tuple stl ->
|
2003-05-19 02:21:17 -07:00
|
|
|
newty (Ttuple(List.map (transl_type env policy) stl))
|
1997-03-07 14:26:29 -08:00
|
|
|
| Ptyp_constr(lid, stl) ->
|
2010-05-18 09:46:46 -07:00
|
|
|
let (path, decl) = find_type env styp.ptyp_loc lid in
|
1995-05-04 03:15:53 -07:00
|
|
|
if List.length stl <> decl.type_arity then
|
|
|
|
raise(Error(styp.ptyp_loc, Type_arity_mismatch(lid, decl.type_arity,
|
|
|
|
List.length stl)));
|
2003-05-19 02:21:17 -07:00
|
|
|
let args = List.map (transl_type env policy) stl in
|
2011-11-24 01:02:48 -08:00
|
|
|
let params = instance_list decl.type_params in
|
2003-03-26 00:24:02 -08:00
|
|
|
let unify_param =
|
|
|
|
match decl.type_manifest with
|
|
|
|
None -> unify_var
|
|
|
|
| Some ty ->
|
|
|
|
if (repr ty).level = Btype.generic_level then unify_var else unify
|
|
|
|
in
|
1997-02-20 12:39:02 -08:00
|
|
|
List.iter2
|
|
|
|
(fun (sty, ty) ty' ->
|
2003-03-26 00:24:02 -08:00
|
|
|
try unify_param env ty' ty with Unify trace ->
|
2002-04-18 00:27:47 -07:00
|
|
|
raise (Error(sty.ptyp_loc, Type_mismatch (swap_list trace))))
|
1997-02-20 12:39:02 -08:00
|
|
|
(List.combine stl args) params;
|
2003-06-30 01:04:42 -07:00
|
|
|
let constr = newconstr path args in
|
|
|
|
begin try
|
|
|
|
Ctype.enforce_constraints env constr
|
|
|
|
with Unify trace ->
|
|
|
|
raise (Error(styp.ptyp_loc, Type_mismatch trace))
|
|
|
|
end;
|
|
|
|
constr
|
1997-03-07 14:26:29 -08:00
|
|
|
| Ptyp_object fields ->
|
2010-01-20 08:26:46 -08:00
|
|
|
newobj (transl_fields env policy [] fields)
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_class(lid, stl, present) ->
|
|
|
|
let (path, decl, is_variant) =
|
1996-04-22 04:15:41 -07:00
|
|
|
try
|
1999-11-30 08:07:38 -08:00
|
|
|
let (path, decl) = Env.lookup_type lid env in
|
2001-09-19 06:09:42 -07:00
|
|
|
let rec check decl =
|
|
|
|
match decl.type_manifest with
|
|
|
|
None -> raise Not_found
|
|
|
|
| Some ty ->
|
|
|
|
match (repr ty).desc with
|
|
|
|
Tvariant row when Btype.static_row row -> ()
|
|
|
|
| Tconstr (path, _, _) ->
|
|
|
|
check (Env.find_type path env)
|
|
|
|
| _ -> raise Not_found
|
|
|
|
in check decl;
|
2001-09-25 02:54:18 -07:00
|
|
|
Location.prerr_warning styp.ptyp_loc Warnings.Deprecated;
|
2001-09-19 06:09:42 -07:00
|
|
|
(path, decl,true)
|
1999-11-30 08:07:38 -08:00
|
|
|
with Not_found -> try
|
|
|
|
if present <> [] then raise Not_found;
|
|
|
|
let lid2 =
|
|
|
|
match lid with
|
|
|
|
Longident.Lident s -> Longident.Lident ("#" ^ s)
|
|
|
|
| Longident.Ldot(r, s) -> Longident.Ldot (r, "#" ^ s)
|
|
|
|
| Longident.Lapply(_, _) -> fatal_error "Typetexp.transl_type"
|
|
|
|
in
|
|
|
|
let (path, decl) = Env.lookup_type lid2 env in
|
|
|
|
(path, decl, false)
|
1996-04-22 04:15:41 -07:00
|
|
|
with Not_found ->
|
1999-11-30 08:07:38 -08:00
|
|
|
raise(Error(styp.ptyp_loc, Unbound_class lid))
|
|
|
|
in
|
1996-04-22 04:15:41 -07:00
|
|
|
if List.length stl <> decl.type_arity then
|
|
|
|
raise(Error(styp.ptyp_loc, Type_arity_mismatch(lid, decl.type_arity,
|
2002-07-23 07:12:03 -07:00
|
|
|
List.length stl)));
|
2003-05-19 02:21:17 -07:00
|
|
|
let args = List.map (transl_type env policy) stl in
|
2011-11-24 01:02:48 -08:00
|
|
|
let params = instance_list decl.type_params in
|
1997-02-20 12:39:02 -08:00
|
|
|
List.iter2
|
2003-03-07 00:59:15 -08:00
|
|
|
(fun (sty, ty) ty' ->
|
|
|
|
try unify_var env ty' ty with Unify trace ->
|
2002-04-18 00:27:47 -07:00
|
|
|
raise (Error(sty.ptyp_loc, Type_mismatch (swap_list trace))))
|
1997-02-20 12:39:02 -08:00
|
|
|
(List.combine stl args) params;
|
2003-06-30 01:04:42 -07:00
|
|
|
let ty =
|
|
|
|
try Ctype.expand_head env (newconstr path args)
|
|
|
|
with Unify trace ->
|
|
|
|
raise (Error(styp.ptyp_loc, Type_mismatch trace))
|
|
|
|
in
|
1999-11-30 08:07:38 -08:00
|
|
|
begin match ty.desc with
|
|
|
|
Tvariant row ->
|
|
|
|
let row = Btype.row_repr row in
|
|
|
|
List.iter
|
|
|
|
(fun l -> if not (List.mem_assoc l row.row_fields) then
|
|
|
|
raise(Error(styp.ptyp_loc, Present_has_no_type l)))
|
|
|
|
present;
|
|
|
|
let fields =
|
|
|
|
List.map
|
|
|
|
(fun (l,f) -> l,
|
|
|
|
if List.mem l present then f else
|
|
|
|
match Btype.row_field_repr f with
|
|
|
|
| Rpresent (Some ty) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
Reither(false, [ty], false, ref None)
|
1999-11-30 08:07:38 -08:00
|
|
|
| Rpresent None ->
|
2003-05-19 02:21:17 -07:00
|
|
|
Reither (true, [], false, ref None)
|
1999-11-30 08:07:38 -08:00
|
|
|
| _ -> f)
|
|
|
|
row.row_fields
|
|
|
|
in
|
2002-06-09 19:39:35 -07:00
|
|
|
let row = { row_closed = true; row_fields = fields;
|
2008-01-11 08:13:18 -08:00
|
|
|
row_bound = (); row_name = Some (path, args);
|
2003-05-19 02:21:17 -07:00
|
|
|
row_fixed = false; row_more = newvar () } in
|
2002-06-09 19:39:35 -07:00
|
|
|
let static = Btype.static_row row in
|
|
|
|
let row =
|
2011-11-24 01:02:48 -08:00
|
|
|
if static then { row with row_more = newty Tnil }
|
|
|
|
else if policy <> Univars then row
|
2007-10-08 07:19:34 -07:00
|
|
|
else { row with row_more = new_pre_univar () }
|
2003-05-19 02:21:17 -07:00
|
|
|
in
|
2002-06-09 19:39:35 -07:00
|
|
|
newty (Tvariant row)
|
2002-04-18 00:27:47 -07:00
|
|
|
| Tobject (fi, _) ->
|
|
|
|
let _, tv = flatten_fields fi in
|
|
|
|
if policy = Univars then pre_univars := tv :: !pre_univars;
|
1999-11-30 08:07:38 -08:00
|
|
|
ty
|
2002-04-18 00:27:47 -07:00
|
|
|
| _ ->
|
|
|
|
assert false
|
1999-11-30 08:07:38 -08:00
|
|
|
end
|
1997-03-07 14:26:29 -08:00
|
|
|
| Ptyp_alias(st, alias) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
begin
|
2002-04-18 00:27:47 -07:00
|
|
|
try
|
2002-06-03 00:33:48 -07:00
|
|
|
let t =
|
2003-05-19 02:21:17 -07:00
|
|
|
try List.assoc alias !univars
|
|
|
|
with Not_found ->
|
2011-11-24 01:02:48 -08:00
|
|
|
instance env (fst(Tbl.find alias !used_variables))
|
2002-06-03 00:33:48 -07:00
|
|
|
in
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty = transl_type env policy st in
|
2002-04-18 00:27:47 -07:00
|
|
|
begin try unify_var env t ty with Unify trace ->
|
|
|
|
let trace = swap_list trace in
|
|
|
|
raise(Error(styp.ptyp_loc, Alias_type_mismatch trace))
|
|
|
|
end;
|
|
|
|
ty
|
|
|
|
with Not_found ->
|
2006-12-21 04:07:53 -08:00
|
|
|
if !Clflags.principal then begin_def ();
|
2002-04-18 00:27:47 -07:00
|
|
|
let t = newvar () in
|
2005-07-21 21:11:47 -07:00
|
|
|
used_variables := Tbl.add alias (t, styp.ptyp_loc) !used_variables;
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty = transl_type env policy st in
|
2002-04-18 00:27:47 -07:00
|
|
|
begin try unify_var env t ty with Unify trace ->
|
|
|
|
let trace = swap_list trace in
|
|
|
|
raise(Error(styp.ptyp_loc, Alias_type_mismatch trace))
|
|
|
|
end;
|
2006-12-21 04:07:53 -08:00
|
|
|
if !Clflags.principal then begin
|
|
|
|
end_def ();
|
|
|
|
generalize_structure t;
|
|
|
|
end;
|
2011-11-24 01:02:48 -08:00
|
|
|
let t = instance env t in
|
2011-09-22 02:05:42 -07:00
|
|
|
let px = Btype.proxy t in
|
|
|
|
begin match px.desc with
|
|
|
|
| Tvar None -> Btype.log_type px; px.desc <- Tvar (Some alias)
|
|
|
|
| Tunivar None -> Btype.log_type px; px.desc <- Tunivar (Some alias)
|
|
|
|
| _ -> ()
|
|
|
|
end;
|
|
|
|
t
|
2002-04-18 00:27:47 -07:00
|
|
|
end
|
1999-11-30 08:07:38 -08:00
|
|
|
| Ptyp_variant(fields, closed, present) ->
|
2008-01-11 08:13:18 -08:00
|
|
|
let name = ref None in
|
2001-09-25 02:54:18 -07:00
|
|
|
let mkfield l f =
|
2002-06-09 19:39:35 -07:00
|
|
|
newty (Tvariant {row_fields=[l,f]; row_more=newvar();
|
2008-01-11 08:13:18 -08:00
|
|
|
row_bound=(); row_closed=true;
|
2003-05-19 02:21:17 -07:00
|
|
|
row_fixed=false; row_name=None}) in
|
2008-01-11 08:13:18 -08:00
|
|
|
let hfields = Hashtbl.create 17 in
|
|
|
|
let add_typed_field loc l f =
|
|
|
|
let h = Btype.hash_variant l in
|
2001-09-25 02:54:18 -07:00
|
|
|
try
|
2008-01-11 08:13:18 -08:00
|
|
|
let (l',f') = Hashtbl.find hfields h in
|
|
|
|
(* Check for tag conflicts *)
|
|
|
|
if l <> l' then raise(Error(styp.ptyp_loc, Variant_tags(l, l')));
|
2001-09-25 02:54:18 -07:00
|
|
|
let ty = mkfield l f and ty' = mkfield l f' in
|
2008-01-11 08:13:18 -08:00
|
|
|
if equal env false [ty] [ty'] then () else
|
|
|
|
try unify env ty ty'
|
2007-10-08 07:19:34 -07:00
|
|
|
with Unify trace -> raise(Error(loc, Constructor_mismatch (ty,ty')))
|
2001-09-25 02:54:18 -07:00
|
|
|
with Not_found ->
|
2008-01-11 08:13:18 -08:00
|
|
|
Hashtbl.add hfields h (l,f)
|
1999-11-30 08:07:38 -08:00
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
let rec add_field = function
|
2001-09-25 02:54:18 -07:00
|
|
|
Rtag (l, c, stl) ->
|
|
|
|
name := None;
|
|
|
|
let f = match present with
|
2005-06-12 18:11:02 -07:00
|
|
|
Some present when not (List.mem l present) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
let tl = List.map (transl_type env policy) stl in
|
|
|
|
Reither(c, tl, false, ref None)
|
2001-09-25 02:54:18 -07:00
|
|
|
| _ ->
|
|
|
|
if List.length stl > 1 || c && stl <> [] then
|
|
|
|
raise(Error(styp.ptyp_loc, Present_has_conjunction l));
|
|
|
|
match stl with [] -> Rpresent None
|
2003-05-19 02:21:17 -07:00
|
|
|
| st :: _ -> Rpresent (Some(transl_type env policy st))
|
2001-09-25 02:54:18 -07:00
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
add_typed_field styp.ptyp_loc l f
|
2001-09-25 02:54:18 -07:00
|
|
|
| Rinherit sty ->
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty = transl_type env policy sty in
|
2001-11-27 18:14:39 -08:00
|
|
|
let nm =
|
2001-09-25 02:54:18 -07:00
|
|
|
match repr ty with
|
2001-11-27 18:14:39 -08:00
|
|
|
{desc=Tconstr(p, tl, _)} -> Some(p, tl)
|
|
|
|
| _ -> None
|
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
begin try
|
|
|
|
(* Set name if there are no fields yet *)
|
|
|
|
Hashtbl.iter (fun _ _ -> raise Exit) hfields;
|
|
|
|
name := nm
|
|
|
|
with Exit ->
|
|
|
|
(* Unset it otherwise *)
|
|
|
|
name := None
|
|
|
|
end;
|
2001-11-27 18:14:39 -08:00
|
|
|
let fl = match expand_head env ty, nm with
|
|
|
|
{desc=Tvariant row}, _ when Btype.static_row row ->
|
2001-09-25 02:54:18 -07:00
|
|
|
let row = Btype.row_repr row in
|
|
|
|
row.row_fields
|
2011-09-22 02:05:42 -07:00
|
|
|
| {desc=Tvar _}, Some(p, _) ->
|
2010-01-22 04:48:24 -08:00
|
|
|
raise(Error(sty.ptyp_loc, Unbound_type_constructor_2 p))
|
2001-11-27 18:14:39 -08:00
|
|
|
| _ ->
|
|
|
|
raise(Error(sty.ptyp_loc, Not_a_variant ty))
|
2001-09-25 02:54:18 -07:00
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
List.iter
|
|
|
|
(fun (l, f) ->
|
2001-09-25 02:54:18 -07:00
|
|
|
let f = match present with
|
2005-06-12 18:11:02 -07:00
|
|
|
Some present when not (List.mem l present) ->
|
2001-09-25 02:54:18 -07:00
|
|
|
begin match f with
|
|
|
|
Rpresent(Some ty) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
Reither(false, [ty], false, ref None)
|
2001-09-25 02:54:18 -07:00
|
|
|
| Rpresent None ->
|
2003-05-19 02:21:17 -07:00
|
|
|
Reither(true, [], false, ref None)
|
2001-09-25 02:54:18 -07:00
|
|
|
| _ ->
|
|
|
|
assert false
|
|
|
|
end
|
|
|
|
| _ -> f
|
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
add_typed_field sty.ptyp_loc l f)
|
|
|
|
fl
|
2001-09-25 02:54:18 -07:00
|
|
|
in
|
2008-01-11 08:13:18 -08:00
|
|
|
List.iter add_field fields;
|
|
|
|
let fields = Hashtbl.fold (fun _ p l -> p :: l) hfields [] in
|
2001-09-25 02:54:18 -07:00
|
|
|
begin match present with None -> ()
|
|
|
|
| Some present ->
|
|
|
|
List.iter
|
|
|
|
(fun l -> if not (List.mem_assoc l fields) then
|
|
|
|
raise(Error(styp.ptyp_loc, Present_has_no_type l)))
|
|
|
|
present
|
|
|
|
end;
|
1999-11-30 08:07:38 -08:00
|
|
|
let row =
|
2001-09-25 02:54:18 -07:00
|
|
|
{ row_fields = List.rev fields; row_more = newvar ();
|
2008-01-11 08:13:18 -08:00
|
|
|
row_bound = (); row_closed = closed;
|
2003-05-19 02:21:17 -07:00
|
|
|
row_fixed = false; row_name = !name } in
|
2002-04-18 00:27:47 -07:00
|
|
|
let static = Btype.static_row row in
|
|
|
|
let row =
|
2011-11-24 01:02:48 -08:00
|
|
|
if static then { row with row_more = newty Tnil }
|
|
|
|
else if policy <> Univars then row
|
2009-07-20 04:51:50 -07:00
|
|
|
else { row with row_more = new_pre_univar () }
|
2007-10-08 07:19:34 -07:00
|
|
|
in
|
1999-11-30 08:07:38 -08:00
|
|
|
newty (Tvariant row)
|
2002-04-18 00:27:47 -07:00
|
|
|
| Ptyp_poly(vars, st) ->
|
2003-05-19 02:21:17 -07:00
|
|
|
begin_def();
|
2011-09-22 02:05:42 -07:00
|
|
|
let new_univars = List.map (fun name -> name, newvar ~name ()) vars in
|
2002-04-18 00:27:47 -07:00
|
|
|
let old_univars = !univars in
|
|
|
|
univars := new_univars @ !univars;
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty = transl_type env policy st in
|
2002-04-18 00:27:47 -07:00
|
|
|
univars := old_univars;
|
2003-05-19 02:21:17 -07:00
|
|
|
end_def();
|
|
|
|
generalize ty;
|
|
|
|
let ty_list =
|
|
|
|
List.fold_left
|
|
|
|
(fun tyl (name, ty1) ->
|
|
|
|
let v = Btype.proxy ty1 in
|
|
|
|
if deep_occur v ty then begin
|
2011-09-22 02:05:42 -07:00
|
|
|
match v.desc with
|
|
|
|
Tvar name when v.level = Btype.generic_level ->
|
|
|
|
v.desc <- Tunivar name;
|
|
|
|
v :: tyl
|
|
|
|
| _ ->
|
|
|
|
raise (Error (styp.ptyp_loc, Cannot_quantify (name, v)))
|
2003-05-19 02:21:17 -07:00
|
|
|
end else tyl)
|
|
|
|
[] new_univars
|
|
|
|
in
|
|
|
|
let ty' = Btype.newgenty (Tpoly(ty, List.rev ty_list)) in
|
|
|
|
unify_var env (newvar()) ty';
|
|
|
|
ty'
|
2009-10-26 03:53:16 -07:00
|
|
|
| Ptyp_package (p, l) ->
|
|
|
|
let l, mty = create_package_mty true styp.ptyp_loc env (p, l) in
|
|
|
|
let z = narrow () in
|
|
|
|
ignore (!transl_modtype env mty);
|
|
|
|
widen z;
|
|
|
|
newty (Tpackage (!transl_modtype_longident styp.ptyp_loc env p,
|
|
|
|
List.map fst l,
|
|
|
|
List.map (transl_type env policy) (List.map snd l)))
|
1996-04-22 04:15:41 -07:00
|
|
|
|
2010-01-20 08:26:46 -08:00
|
|
|
and transl_fields env policy seen =
|
1996-04-22 04:15:41 -07:00
|
|
|
function
|
|
|
|
[] ->
|
|
|
|
newty Tnil
|
2009-07-20 04:51:50 -07:00
|
|
|
| {pfield_desc = Pfield_var}::_ ->
|
|
|
|
if policy = Univars then new_pre_univar () else newvar ()
|
2010-01-20 08:26:46 -08:00
|
|
|
| {pfield_desc = Pfield(s, e); pfield_loc = loc}::l ->
|
|
|
|
if List.mem s seen then raise (Error (loc, Repeated_method_label s));
|
2003-05-19 02:21:17 -07:00
|
|
|
let ty1 = transl_type env policy e in
|
2010-01-20 08:26:46 -08:00
|
|
|
let ty2 = transl_fields env policy (s::seen) l in
|
1997-05-11 14:48:21 -07:00
|
|
|
newty (Tfield (s, Fpresent, ty1, ty2))
|
1995-05-04 03:15:53 -07:00
|
|
|
|
2003-05-19 02:21:17 -07:00
|
|
|
|
|
|
|
(* Make the rows "fixed" in this type, to make universal check easier *)
|
|
|
|
let rec make_fixed_univars ty =
|
|
|
|
let ty = repr ty in
|
|
|
|
if ty.level >= Btype.lowest_level then begin
|
|
|
|
Btype.mark_type_node ty;
|
|
|
|
match ty.desc with
|
|
|
|
| Tvariant row ->
|
|
|
|
let row = Btype.row_repr row in
|
2011-09-22 02:05:42 -07:00
|
|
|
if Btype.is_Tunivar (Btype.row_more row) then
|
2003-05-19 02:21:17 -07:00
|
|
|
ty.desc <- Tvariant
|
|
|
|
{row with row_fixed=true;
|
|
|
|
row_fields = List.map
|
|
|
|
(fun (s,f as p) -> match Btype.row_field_repr f with
|
|
|
|
Reither (c, tl, m, r) -> s, Reither (c, tl, true, r)
|
|
|
|
| _ -> p)
|
|
|
|
row.row_fields};
|
|
|
|
Btype.iter_row make_fixed_univars row
|
|
|
|
| _ ->
|
|
|
|
Btype.iter_type_expr make_fixed_univars ty
|
|
|
|
end
|
|
|
|
|
|
|
|
let make_fixed_univars ty =
|
|
|
|
make_fixed_univars ty;
|
|
|
|
Btype.unmark_type ty
|
|
|
|
|
2009-10-26 03:53:16 -07:00
|
|
|
let create_package_mty = create_package_mty false
|
|
|
|
|
2005-07-21 23:42:36 -07:00
|
|
|
let globalize_used_variables env fixed =
|
|
|
|
let r = ref [] in
|
2005-07-21 21:11:47 -07:00
|
|
|
Tbl.iter
|
|
|
|
(fun name (ty, loc) ->
|
|
|
|
let v = new_global_var () in
|
|
|
|
let snap = Btype.snapshot () in
|
|
|
|
if try unify env v ty; true with _ -> Btype.backtrack snap; false
|
|
|
|
then try
|
2005-07-21 23:42:36 -07:00
|
|
|
r := (loc, v, Tbl.find name !type_variables) :: !r
|
|
|
|
with Not_found ->
|
2011-09-22 02:05:42 -07:00
|
|
|
if fixed && Btype.is_Tvar (repr ty) then
|
2005-07-21 23:42:36 -07:00
|
|
|
raise(Error(loc, Unbound_type_variable ("'"^name)));
|
|
|
|
let v2 = new_global_var () in
|
|
|
|
r := (loc, v, v2) :: !r;
|
|
|
|
type_variables := Tbl.add name v2 !type_variables)
|
2005-07-21 21:11:47 -07:00
|
|
|
!used_variables;
|
2005-07-21 23:42:36 -07:00
|
|
|
used_variables := Tbl.empty;
|
|
|
|
fun () ->
|
|
|
|
List.iter
|
|
|
|
(function (loc, t1, t2) ->
|
|
|
|
try unify env t1 t2 with Unify trace ->
|
|
|
|
raise (Error(loc, Type_mismatch trace)))
|
|
|
|
!r
|
2005-07-21 21:11:47 -07:00
|
|
|
|
1997-01-20 09:11:47 -08:00
|
|
|
let transl_simple_type env fixed styp =
|
2005-07-21 21:11:47 -07:00
|
|
|
univars := []; used_variables := Tbl.empty;
|
2003-05-19 02:21:17 -07:00
|
|
|
let typ = transl_type env (if fixed then Fixed else Extensible) styp in
|
2005-07-21 23:42:36 -07:00
|
|
|
globalize_used_variables env fixed ();
|
2003-05-19 02:21:17 -07:00
|
|
|
make_fixed_univars typ;
|
1997-01-20 09:11:47 -08:00
|
|
|
typ
|
|
|
|
|
2002-04-18 00:27:47 -07:00
|
|
|
let transl_simple_type_univars env styp =
|
2005-07-21 21:11:47 -07:00
|
|
|
univars := []; used_variables := Tbl.empty; pre_univars := [];
|
2002-04-18 00:27:47 -07:00
|
|
|
begin_def ();
|
2003-05-19 02:21:17 -07:00
|
|
|
let typ = transl_type env Univars styp in
|
2005-07-21 21:11:47 -07:00
|
|
|
(* Only keep already global variables in used_variables *)
|
|
|
|
let new_variables = !used_variables in
|
|
|
|
used_variables := Tbl.empty;
|
|
|
|
Tbl.iter
|
|
|
|
(fun name p ->
|
|
|
|
if Tbl.mem name !type_variables then
|
|
|
|
used_variables := Tbl.add name p !used_variables)
|
|
|
|
new_variables;
|
2005-07-21 23:42:36 -07:00
|
|
|
globalize_used_variables env false ();
|
2002-04-18 00:27:47 -07:00
|
|
|
end_def ();
|
|
|
|
generalize typ;
|
|
|
|
let univs =
|
|
|
|
List.fold_left
|
|
|
|
(fun acc v ->
|
|
|
|
let v = repr v in
|
2011-09-22 02:05:42 -07:00
|
|
|
match v.desc with
|
|
|
|
Tvar name when v.level = Btype.generic_level ->
|
|
|
|
v.desc <- Tunivar name; v :: acc
|
|
|
|
| _ -> acc)
|
2002-04-18 00:27:47 -07:00
|
|
|
[] !pre_univars
|
|
|
|
in
|
2003-05-19 02:21:17 -07:00
|
|
|
make_fixed_univars typ;
|
2011-11-24 01:02:48 -08:00
|
|
|
instance env (Btype.newgenty (Tpoly (typ, univs)))
|
2002-04-18 00:27:47 -07:00
|
|
|
|
1997-01-20 09:11:47 -08:00
|
|
|
let transl_simple_type_delayed env styp =
|
2005-07-21 21:11:47 -07:00
|
|
|
univars := []; used_variables := Tbl.empty;
|
|
|
|
let typ = transl_type env Extensible styp in
|
2009-10-26 00:11:36 -07:00
|
|
|
make_fixed_univars typ;
|
2005-07-21 23:42:36 -07:00
|
|
|
(typ, globalize_used_variables env false)
|
1997-01-20 09:11:47 -08:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
let transl_type_scheme env styp =
|
|
|
|
reset_type_variables();
|
|
|
|
begin_def();
|
|
|
|
let typ = transl_simple_type env false styp in
|
|
|
|
end_def();
|
|
|
|
generalize typ;
|
|
|
|
typ
|
|
|
|
|
2010-05-18 09:46:46 -07:00
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
(* Error report *)
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
open Format
|
1995-05-04 03:15:53 -07:00
|
|
|
open Printtyp
|
|
|
|
|
2000-03-06 14:12:09 -08:00
|
|
|
let report_error ppf = function
|
|
|
|
| Unbound_type_variable name ->
|
|
|
|
fprintf ppf "Unbound type parameter %s" name
|
1995-05-04 03:15:53 -07:00
|
|
|
| Unbound_type_constructor lid ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "Unbound type constructor %a" longident lid
|
2001-11-27 18:14:39 -08:00
|
|
|
| Unbound_type_constructor_2 p ->
|
|
|
|
fprintf ppf "The type constructor@ %a@ is not yet completely defined"
|
|
|
|
path p
|
1995-05-04 03:15:53 -07:00
|
|
|
| Type_arity_mismatch(lid, expected, provided) ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf
|
|
|
|
"@[The type constructor %a@ expects %i argument(s),@ \
|
|
|
|
but is here applied to %i argument(s)@]"
|
|
|
|
longident lid expected provided
|
1996-04-22 04:15:41 -07:00
|
|
|
| Bound_type_variable name ->
|
2001-11-15 23:26:56 -08:00
|
|
|
fprintf ppf "Already bound type parameter '%s" name
|
1996-04-22 04:15:41 -07:00
|
|
|
| Recursive_type ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "This type is recursive"
|
1996-04-22 04:15:41 -07:00
|
|
|
| Unbound_row_variable lid ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "Unbound row variable in #%a" longident lid
|
1997-02-20 12:39:02 -08:00
|
|
|
| Type_mismatch trace ->
|
1998-08-15 06:49:41 -07:00
|
|
|
Printtyp.unification_error true trace
|
2000-03-06 14:12:09 -08:00
|
|
|
(function ppf ->
|
|
|
|
fprintf ppf "This type")
|
|
|
|
ppf
|
|
|
|
(function ppf ->
|
|
|
|
fprintf ppf "should be an instance of type")
|
1997-02-20 12:39:02 -08:00
|
|
|
| Alias_type_mismatch trace ->
|
1998-08-15 06:49:41 -07:00
|
|
|
Printtyp.unification_error true trace
|
2000-03-06 14:12:09 -08:00
|
|
|
(function ppf ->
|
|
|
|
fprintf ppf "This alias is bound to type")
|
|
|
|
ppf
|
|
|
|
(function ppf ->
|
|
|
|
fprintf ppf "but is used as an instance of type")
|
1999-11-30 08:07:38 -08:00
|
|
|
| Present_has_conjunction l ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "The present constructor %s has a conjunctive type" l
|
1999-11-30 08:07:38 -08:00
|
|
|
| Present_has_no_type l ->
|
2000-03-06 14:12:09 -08:00
|
|
|
fprintf ppf "The present constructor %s has no type" l
|
2001-09-25 02:54:18 -07:00
|
|
|
| Constructor_mismatch (ty, ty') ->
|
|
|
|
Printtyp.reset_and_mark_loops_list [ty; ty'];
|
|
|
|
fprintf ppf "@[<hov>%s %a@ %s@ %a@]"
|
|
|
|
"This variant type contains a constructor"
|
|
|
|
Printtyp.type_expr ty
|
|
|
|
"which should be"
|
|
|
|
Printtyp.type_expr ty'
|
|
|
|
| Not_a_variant ty ->
|
|
|
|
Printtyp.reset_and_mark_loops ty;
|
|
|
|
fprintf ppf "@[The type %a@ is not a polymorphic variant type@]"
|
|
|
|
Printtyp.type_expr ty
|
2002-01-03 18:02:50 -08:00
|
|
|
| Variant_tags (lab1, lab2) ->
|
|
|
|
fprintf ppf
|
2011-11-24 01:02:48 -08:00
|
|
|
"@[Variant tags `%s@ and `%s have the same hash value.@ %s@]"
|
|
|
|
lab1 lab2 "Change one of them."
|
2003-03-07 00:59:15 -08:00
|
|
|
| Invalid_variable_name name ->
|
|
|
|
fprintf ppf "The type variable name %s is not allowed in programs" name
|
2003-05-19 02:21:17 -07:00
|
|
|
| Cannot_quantify (name, v) ->
|
2011-11-24 01:02:48 -08:00
|
|
|
fprintf ppf
|
|
|
|
"@[<hov>The universal type variable '%s cannot be generalized:@ %s.@]"
|
|
|
|
name
|
|
|
|
(if Btype.is_Tvar v then "it escapes its scope" else
|
|
|
|
if Btype.is_Tunivar v then "it is already bound to another variable"
|
2003-05-19 02:21:17 -07:00
|
|
|
else "it is not a variable")
|
2009-10-26 03:53:16 -07:00
|
|
|
| Multiple_constraints_on_type s ->
|
|
|
|
fprintf ppf "Multiple constraints for type %s" s
|
2010-01-20 08:26:46 -08:00
|
|
|
| Repeated_method_label s ->
|
|
|
|
fprintf ppf "@[This is the second method `%s' of this object type.@ %s@]"
|
|
|
|
s "Multiple occurences are not allowed."
|
2010-05-18 09:46:46 -07:00
|
|
|
| Unbound_value lid ->
|
|
|
|
fprintf ppf "Unbound value %a" longident lid
|
|
|
|
| Unbound_module lid ->
|
|
|
|
fprintf ppf "Unbound module %a" longident lid
|
|
|
|
| Unbound_constructor lid ->
|
|
|
|
fprintf ppf "Unbound constructor %a" longident lid
|
|
|
|
| Unbound_label lid ->
|
|
|
|
fprintf ppf "Unbound record field label %a" longident lid
|
|
|
|
| Unbound_class lid ->
|
|
|
|
fprintf ppf "Unbound class %a" longident lid
|
2010-05-18 10:18:24 -07:00
|
|
|
| Unbound_modtype lid ->
|
|
|
|
fprintf ppf "Unbound module type %a" longident lid
|
2010-05-18 10:25:02 -07:00
|
|
|
| Unbound_cltype lid ->
|
|
|
|
fprintf ppf "Unbound class type %a" longident lid
|
2010-05-18 09:46:46 -07:00
|
|
|
| Ill_typed_functor_application lid ->
|
|
|
|
fprintf ppf "Ill-typed functor application %a" longident lid
|