diff options
author | Damien Doligez <damien.doligez-inria.fr> | 1997-05-19 15:42:21 +0000 |
---|---|---|
committer | Damien Doligez <damien.doligez-inria.fr> | 1997-05-19 15:42:21 +0000 |
commit | 03ec746bf1afc498c91a4bff3a3f80d873594b95 (patch) | |
tree | 2d628930d146a469503d32f62181997a75e459a3 /typing | |
parent | 9f30d68f00c8933445d45416dcc7f67c7f1ca934 (diff) | |
download | ocaml-03ec746bf1afc498c91a4bff3a3f80d873594b95.tar.gz |
deTABisation
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@1563 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'typing')
-rw-r--r-- | typing/ctype.mli | 18 | ||||
-rw-r--r-- | typing/datarepr.ml | 2 | ||||
-rw-r--r-- | typing/env.ml | 64 | ||||
-rw-r--r-- | typing/includecore.mli | 2 | ||||
-rw-r--r-- | typing/includemod.ml | 2 | ||||
-rw-r--r-- | typing/mtype.ml | 4 | ||||
-rw-r--r-- | typing/subst.ml | 4 | ||||
-rw-r--r-- | typing/typeclass.ml | 112 | ||||
-rw-r--r-- | typing/typecore.ml | 88 | ||||
-rw-r--r-- | typing/typecore.mli | 2 | ||||
-rw-r--r-- | typing/typemod.ml | 10 | ||||
-rw-r--r-- | typing/types.ml | 6 | ||||
-rw-r--r-- | typing/types.mli | 6 |
13 files changed, 160 insertions, 160 deletions
diff --git a/typing/ctype.mli b/typing/ctype.mli index 85e7bca1e6..426f57fa70 100644 --- a/typing/ctype.mli +++ b/typing/ctype.mli @@ -47,11 +47,11 @@ val repr: type_expr -> type_expr val flatten_fields : type_expr -> (string * field_kind * type_expr) list * type_expr - (* Transform a field type into a list of pairs label-type *) + (* Transform a field type into a list of pairs label-type *) val opened_object: type_expr -> bool val close_object: type_expr -> unit val set_object_name: - type_expr -> type_expr list -> Ident.t -> unit + type_expr -> type_expr list -> Ident.t -> unit val remove_object_name: type_expr -> unit val hide_private_methods: type_expr -> unit @@ -72,12 +72,12 @@ val instance_constructor: val instance_label: label_description -> type_expr * type_expr (* Same, for a label *) val instance_parameterized_type: - type_expr list -> type_expr -> type_expr list * type_expr + type_expr list -> type_expr -> type_expr list * type_expr val instance_parameterized_type_2: - type_expr list -> type_expr list -> type_expr -> + type_expr list -> type_expr list -> type_expr -> type_expr list * type_expr list * type_expr val instance_class: - class_type -> + class_type -> type_expr list * type_expr list * (mutable_flag * type_expr) Vars.t * type_expr Meths.t * type_expr val apply: @@ -88,8 +88,8 @@ val apply: val expand_abbrev: Env.t -> Path.t -> type_expr list -> Types.abbrev_memo ref -> - int -> type_expr - (* Expand an abbreviation *) + int -> type_expr + (* Expand an abbreviation *) val expand_head: Env.t -> type_expr -> type_expr val full_expand: Env.t -> type_expr -> type_expr @@ -98,7 +98,7 @@ val unify: Env.t -> type_expr -> type_expr -> unit val filter_arrow: Env.t -> type_expr -> type_expr * type_expr (* A special case of unification (with 'a -> 'b). *) val filter_method: Env.t -> string -> private_flag -> type_expr -> type_expr - (* A special case of unification (with {m : 'a; 'b}). *) + (* A special case of unification (with {m : 'a; 'b}). *) val moregeneral: Env.t -> bool -> type_expr -> type_expr -> bool (* Check if the first type scheme is more general than the second. *) @@ -109,7 +109,7 @@ val equal: Env.t -> bool -> type_expr list -> type_expr list -> bool [/\x1.../\xn.tau] and [/\y1.../\yn.sigma] are equivalent. *) val enlarge_type: Env.t -> type_expr -> type_expr - (* Make a type larger *) + (* Make a type larger *) val subtype : Env.t -> type_expr -> type_expr -> unit -> unit (* [subtype env t1 t2] checks that [t1] is a subtype of [t2]. It accumulates the constraints the type variables must diff --git a/typing/datarepr.ml b/typing/datarepr.ml index 40c211a4a8..df9491d959 100644 --- a/typing/datarepr.ml +++ b/typing/datarepr.ml @@ -52,7 +52,7 @@ let exception_descr path_exc decl = cstr_nonconsts = -1 } let none = {desc = Ttuple []; level = -1} - (* Clearly ill-formed type *) + (* Clearly ill-formed type *) let dummy_label = { lbl_res = none; lbl_arg = none; lbl_mut = Immutable; lbl_pos = (-1); lbl_all = [||]; lbl_repres = Record_regular } diff --git a/typing/env.ml b/typing/env.ml index e72272dcdc..0e12be9261 100644 --- a/typing/env.ml +++ b/typing/env.ml @@ -152,18 +152,18 @@ let rec find_module_descr path env = end | Pdot(p, s, pos) -> begin match find_module_descr p env with - Structure_comps c -> - let (descr, pos) = Tbl.find s c.comp_components in + Structure_comps c -> + let (descr, pos) = Tbl.find s c.comp_components in descr | Functor_comps f -> - raise Not_found + raise Not_found end | Papply(p1, p2) -> begin match find_module_descr p1 env with - Functor_comps f -> + Functor_comps f -> !components_of_functor_appl f p1 p2 | Structure_comps c -> - raise Not_found + raise Not_found end let find proj1 proj2 path env = @@ -237,21 +237,21 @@ let rec lookup_module_descr lid env = | Ldot(l, s) -> let (p, descr) = lookup_module_descr l env in begin match descr with - Structure_comps c -> - let (descr, pos) = Tbl.find s c.comp_components in + Structure_comps c -> + let (descr, pos) = Tbl.find s c.comp_components in (Pdot(p, s, pos), descr) | Functor_comps f -> - raise Not_found + raise Not_found end | Lapply(l1, l2) -> let (p1, desc1) = lookup_module_descr l1 env in let (p2, mty2) = lookup_module l2 env in begin match desc1 with - Functor_comps f -> + Functor_comps f -> !check_modtype_inclusion env mty2 f.fcomp_arg; (Papply(p1, p2), !components_of_functor_appl f p1 p2) | Structure_comps c -> - raise Not_found + raise Not_found end and lookup_module lid env = @@ -266,23 +266,23 @@ and lookup_module lid env = | Ldot(l, s) -> let (p, descr) = lookup_module_descr l env in begin match descr with - Structure_comps c -> + Structure_comps c -> let (data, pos) = Tbl.find s c.comp_modules in (Pdot(p, s, pos), data) | Functor_comps f -> - raise Not_found + raise Not_found end | Lapply(l1, l2) -> let (p1, desc1) = lookup_module_descr l1 env in let (p2, mty2) = lookup_module l2 env in let p = Papply(p1, p2) in begin match desc1 with - Functor_comps f -> + Functor_comps f -> !check_modtype_inclusion env mty2 f.fcomp_arg; (p, Subst.modtype (Subst.add_module f.fcomp_param p2 Subst.identity) - f.fcomp_res) + f.fcomp_res) | Structure_comps c -> - raise Not_found + raise Not_found end let lookup proj1 proj2 lid env = @@ -291,11 +291,11 @@ let lookup proj1 proj2 lid env = Ident.find_name s (proj1 env) | Ldot(l, s) -> begin match lookup_module_descr l env with - (p, Structure_comps c) -> - let (data, pos) = Tbl.find s (proj2 c) in + (p, Structure_comps c) -> + let (data, pos) = Tbl.find s (proj2 c) in (Pdot(p, s, pos), data) | (p, Functor_comps f) -> - raise Not_found + raise Not_found end | Lapply(l1, l2) -> raise Not_found @@ -306,11 +306,11 @@ let lookup_simple proj1 proj2 lid env = Ident.find_name s (proj1 env) | Ldot(l, s) -> begin match lookup_module_descr l env with - (p, Structure_comps c) -> - let (data, pos) = Tbl.find s (proj2 c) in + (p, Structure_comps c) -> + let (data, pos) = Tbl.find s (proj2 c) in data | (p, Functor_comps f) -> - raise Not_found + raise Not_found end | Lapply(l1, l2) -> raise Not_found @@ -451,22 +451,22 @@ let rec components_of_module env sub path mty = c.comp_modtypes <- Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes; env := store_modtype id path decl' !env - | Tsig_class(id, decl) -> - let decl' = Subst.class_type sub decl in + | Tsig_class(id, decl) -> + let decl' = Subst.class_type sub decl in c.comp_classes <- Tbl.add (Ident.name id) (decl', !pos) c.comp_classes; - incr pos) + incr pos) sg pl; - Structure_comps c + Structure_comps c | Tmty_functor(param, ty_arg, ty_res) -> - Functor_comps { - fcomp_param = param; - fcomp_arg = Subst.modtype sub ty_arg; - fcomp_res = Subst.modtype sub ty_res; - fcomp_env = env } + Functor_comps { + fcomp_param = param; + fcomp_arg = Subst.modtype sub ty_arg; + fcomp_res = Subst.modtype sub ty_res; + fcomp_env = env } | Tmty_ident p -> - Structure_comps { - comp_values = Tbl.empty; comp_constrs = Tbl.empty; + Structure_comps { + comp_values = Tbl.empty; comp_constrs = Tbl.empty; comp_labels = Tbl.empty; comp_types = Tbl.empty; comp_modules = Tbl.empty; comp_modtypes = Tbl.empty; comp_components = Tbl.empty; comp_classes = Tbl.empty } diff --git a/typing/includecore.mli b/typing/includecore.mli index c426ad8fb7..11fe4e4a29 100644 --- a/typing/includecore.mli +++ b/typing/includecore.mli @@ -25,4 +25,4 @@ val type_declarations: val exception_declarations: Env.t -> exception_declaration -> exception_declaration -> bool val class_types: - Env.t -> class_type -> class_type -> bool + Env.t -> class_type -> class_type -> bool diff --git a/typing/includemod.ml b/typing/includemod.ml index 35c0159752..0a962142b1 100644 --- a/typing/includemod.ml +++ b/typing/includemod.ml @@ -177,7 +177,7 @@ and signatures env subst sig1 sig2 = | Tsig_value(_,_) | Tsig_exception(_,_) | Tsig_module(_,_) - | Tsig_class(_, _) -> pos+1 in + | Tsig_class(_, _) -> pos+1 in build_component_table nextpos (Tbl.add name (id, item, pos) tbl) rem in let comps1 = diff --git a/typing/mtype.ml b/typing/mtype.ml index b1e45ff617..09d71f0624 100644 --- a/typing/mtype.ml +++ b/typing/mtype.ml @@ -49,9 +49,9 @@ and strengthen_sig env sg p = type_arity = decl.type_arity; type_kind = decl.type_kind; type_manifest = Some(Ctype.newgenty( - Tconstr(Pdot(p, Ident.name id, nopos), + Tconstr(Pdot(p, Ident.name id, nopos), decl.type_params, - ref Mnil))) } + ref Mnil))) } | _ -> decl in Tsig_type(id, newdecl) :: strengthen_sig env rem p | (Tsig_exception(id, d) as sigelt) :: rem -> diff --git a/typing/subst.ml b/typing/subst.ml index 4e199642e3..ba036f4a49 100644 --- a/typing/subst.ml +++ b/typing/subst.ml @@ -169,9 +169,9 @@ let class_type s decl = cty_concr = decl.cty_concr; cty_new = begin match decl.cty_new with - None -> None + None -> None | Some ty -> Some (typexp s ty) - end } + end } in cleanup_types (); List.iter unmark_type decl.cty_params; diff --git a/typing/typeclass.ml b/typing/typeclass.ml index 1622816736..520998fd2e 100644 --- a/typing/typeclass.ml +++ b/typing/typeclass.ml @@ -156,11 +156,11 @@ let missing_method env ty ty' = Tfield(lab, k, _, met') -> begin try if Btype.field_kind_repr k = Fpresent then begin - Ctype.filter_method env lab Public ty; () + Ctype.filter_method env lab Public ty; () end; - missing_method_rec met' + missing_method_rec met' with Ctype.Unify _ -> - lab + lab end | _ -> fatal_error "Typeclass.missing_method (1)" @@ -195,28 +195,28 @@ let make_stub env (cl, obj_id, cl_id) = let concr_meths = List.fold_left (function meths -> - function - Pcf_inher (nm, _, _, _, loc) -> + function + Pcf_inher (nm, _, _, _, loc) -> let (_, anc) = - try - Env.lookup_class nm env - with Not_found -> - raise(Error(loc, Unbound_class nm)) + try + Env.lookup_class nm env + with Not_found -> + raise(Error(loc, Unbound_class nm)) in - begin match (Ctype.expand_head env anc.cty_self).desc with + begin match (Ctype.expand_head env anc.cty_self).desc with Tobject (ty, _) -> add_methods env self ty; - Concr.union anc.cty_concr meths + Concr.union anc.cty_concr meths | _ -> fatal_error "Typeclass.make_stub" end - | Pcf_val _ -> - meths - | Pcf_virt (lab, priv, _, _) -> - Ctype.filter_method env lab priv self; - meths - | Pcf_meth (lab, priv, _, _) -> - Ctype.filter_method env lab priv self; - Concr.add lab meths) + | Pcf_val _ -> + meths + | Pcf_virt (lab, priv, _, _) -> + Ctype.filter_method env lab priv self; + meths + | Pcf_meth (lab, priv, _, _) -> + Ctype.filter_method env lab priv self; + Concr.add lab meths) Concr.empty cl.pcl_field in @@ -397,10 +397,10 @@ let type_class_field env var_env self cl {val_type = exp.exp_type; val_kind = Val_ivar mut} met_env in (met_env, Cf_val (lab, id, priv, Some exp)::fields, - insert_value var_env lab priv mut exp.exp_type loc vars_sig, + insert_value var_env lab priv mut exp.exp_type loc vars_sig, meths) | None -> - let (vars_sig, ty) = + let (vars_sig, ty) = change_value_status lab priv mut loc vars_sig in let (id, met_env) = @@ -499,9 +499,9 @@ let transl_class temp_env env List.iter2 (Ctype.unify temp_env) temp_cl_params cl_params with Ctype.Unify _ -> raise(Error(cl.pcl_loc, - Bad_parameters (cl_id, cl_abbrev, - Ctype.newty (Tconstr (Path.Pident cl_id, cl_params, - ref Mnil))))) + Bad_parameters (cl_id, cl_abbrev, + Ctype.newty (Tconstr (Path.Pident cl_id, cl_params, + ref Mnil))))) end; (* Object abbreviation and arguments for new *) @@ -516,16 +516,16 @@ let transl_class temp_env env with Ctype.Unify _ -> raise(Error(cl.pcl_loc, Bad_parameters (obj_id, abbrev, - Ctype.newty (Tconstr (Path.Pident obj_id, obj_params, - ref Mnil))))) + Ctype.newty (Tconstr (Path.Pident obj_id, obj_params, + ref Mnil))))) end; Ctype.close_object temp_obj; List.iter2 (fun ty (exp, ty') -> begin try - Ctype.unify temp_env ty' ty + Ctype.unify temp_env ty' ty with Ctype.Unify trace -> - raise(Error(exp.pat_loc, Argument_type_mismatch trace)) + raise(Error(exp.pat_loc, Argument_type_mismatch trace)) end) new_args (List.combine args arg_sig'); @@ -557,7 +557,7 @@ let build_new_type temp_env env (* Modify constrainsts to ensure the object abbreviation is well-formed *) let (params, args, vars, meths, self) = Ctype.instance_class cl_sig in List.iter2 (Ctype.unify temp_env) params temp_obj_params; - (* Never fails *) + (* Never fails *) (* Hide private methods *) Ctype.hide_private_methods cl_sig.cty_self; @@ -602,7 +602,7 @@ let build_new_type temp_env env cty_meths = meths; cty_self = exp_self; cty_concr = cl_sig.cty_concr; - cty_new = cl_sig.cty_new } (* new is still monomorphic *) + cty_new = cl_sig.cty_new } (* new is still monomorphic *) in let new_env = Env.add_class id cl_sig env in ((cl, id, cl_id, obj_id, cl_sig, cl_imp), new_env) @@ -690,28 +690,28 @@ let make_stub env (cl, obj_id, cl_id) = let concr_meths = List.fold_left (function meths -> - function - Pctf_inher (nm, _, loc) -> + function + Pctf_inher (nm, _, loc) -> let (_, anc) = - try - Env.lookup_class nm env - with Not_found -> - raise(Error(loc, Unbound_class nm)) + try + Env.lookup_class nm env + with Not_found -> + raise(Error(loc, Unbound_class nm)) in - begin match (Ctype.expand_head env anc.cty_self).desc with + begin match (Ctype.expand_head env anc.cty_self).desc with Tobject (ty, _) -> add_methods env self ty; - Concr.union anc.cty_concr meths + Concr.union anc.cty_concr meths | _ -> fatal_error "Typeclass.make_stub (type)" end - | Pctf_val _ -> - meths - | Pctf_virt (lab, priv, _, _) -> - Ctype.filter_method env lab priv self; - meths - | Pctf_meth (lab, priv, _, _) -> - Ctype.filter_method env lab priv self; - Concr.add lab meths) + | Pctf_val _ -> + meths + | Pctf_virt (lab, priv, _, _) -> + Ctype.filter_method env lab priv self; + meths + | Pctf_meth (lab, priv, _, _) -> + Ctype.filter_method env lab priv self; + Concr.add lab meths) Concr.empty cl.pcty_field in @@ -836,11 +836,11 @@ let type_class_field env var_env self cl (vars_sig, meths_sig) = | Pctf_val (lab, priv, mut, sty, loc) -> begin match sty with - Some sty -> + Some sty -> let ty = transl_simple_type var_env false sty in (insert_value var_env lab priv mut ty loc vars_sig, meths_sig) | None -> - (fst (change_value_status lab priv mut loc vars_sig), meths_sig) + (fst (change_value_status lab priv mut loc vars_sig), meths_sig) end | Pctf_virt (lab, priv, sty, loc) -> @@ -930,9 +930,9 @@ let transl_class temp_env env List.iter2 (Ctype.unify temp_env) temp_cl_params cl_params with Ctype.Unify _ -> raise(Error(cl.pcty_loc, - Bad_parameters (cl_id, cl_abbrev, - Ctype.newty (Tconstr (Path.Pident cl_id, cl_params, - ref Mnil))))) + Bad_parameters (cl_id, cl_abbrev, + Ctype.newty (Tconstr (Path.Pident cl_id, cl_params, + ref Mnil))))) end; (* Object abbreviation and arguments for new *) @@ -947,8 +947,8 @@ let transl_class temp_env env with Ctype.Unify _ -> raise(Error(cl.pcty_loc, Bad_parameters (obj_id, abbrev, - Ctype.newty (Tconstr (Path.Pident obj_id, obj_params, - ref Mnil))))) + Ctype.newty (Tconstr (Path.Pident obj_id, obj_params, + ref Mnil))))) end; Ctype.close_object temp_obj; @@ -975,7 +975,7 @@ let build_new_type temp_env env (* Modify constrainsts to ensure the object abbreviation is well-formed *) let (params, args, vars, meths, self) = Ctype.instance_class cl_sig in List.iter2 (Ctype.unify temp_env) params temp_obj_params; - (* Never fails *) + (* Never fails *) (* Hide private methods *) Ctype.hide_private_methods cl_sig.cty_self; @@ -1037,12 +1037,12 @@ let make_abbrev env type_kind = Type_abstract; type_manifest = Some (if cl.pcty_closed = Closed then - Ctype.newgenty (Tconstr(Path.Pident obj_id, cl_sig.cty_params, + Ctype.newgenty (Tconstr(Path.Pident obj_id, cl_sig.cty_params, ref Mnil)) else begin Ctype.set_object_name cl_sig.cty_self cl_sig.cty_params obj_id; cl_sig.cty_self - end) } + end) } in let new_env = Env.add_type cl_id cl_abbrev env in (* Object type abbreviation *) diff --git a/typing/typecore.ml b/typing/typecore.ml index 0ce889fa4f..e839f70174 100644 --- a/typing/typecore.ml +++ b/typing/typecore.ml @@ -255,11 +255,11 @@ let type_format loc fmt = | 'a' -> let ty_arg = newvar() in newty (Tarrow (newty (Tarrow(ty_input, - newty (Tarrow (ty_arg, ty_result)))), + newty (Tarrow (ty_arg, ty_result)))), newty (Tarrow (ty_arg, scan_format (j+1))))) | 't' -> newty (Tarrow(newty (Tarrow(ty_input, ty_result)), - scan_format (j+1))) + scan_format (j+1))) | c -> raise(Error(loc, Bad_format(String.sub fmt i (j-i)))) end @@ -282,14 +282,14 @@ let rec type_exp env sexp = let (path, desc) = Env.lookup_value lid env in { exp_desc = begin match (desc.val_kind, lid) with - (Val_ivar _, Longident.Lident lab) -> - let (path_self, _) = + (Val_ivar _, Longident.Lident lab) -> + let (path_self, _) = Env.lookup_value (Longident.Lident "*self*") env in Texp_instvar (path_self, path) - | _ -> - Texp_ident(path, desc) - end; + | _ -> + Texp_ident(path, desc) + end; exp_loc = sexp.pexp_loc; exp_type = instance desc.val_type; exp_env = env } @@ -495,13 +495,13 @@ let rec type_exp env sexp = | Pexp_constraint(sarg, sty, sty') -> let (arg, ty') = match (sty, sty') with - (None, None) -> (* Case actually unused *) + (None, None) -> (* Case actually unused *) let arg = type_exp env sarg in - (arg, arg.exp_type) - | (Some sty, None) -> + (arg, arg.exp_type) + | (Some sty, None) -> let ty = Typetexp.transl_simple_type env false sty in (type_expect env sarg ty, ty) - | (None, Some sty') -> + | (None, Some sty') -> let (ty', force) = Typetexp.transl_simple_type_delayed env sty' in @@ -513,7 +513,7 @@ let rec type_exp env sexp = Coercion_failure(ty', full_expand env ty', trace))) end; (arg, ty') - | (Some sty, Some sty') -> + | (Some sty, Some sty') -> let (ty, force) = Typetexp.transl_simple_type_delayed env sty and (ty', force') = @@ -523,9 +523,9 @@ let rec type_exp env sexp = let force'' = subtype env ty ty' in force (); force' (); force'' () with Subtype (tr1, tr2) -> - raise(Error(sexp.pexp_loc, Not_subtype(tr1, tr2))) + raise(Error(sexp.pexp_loc, Not_subtype(tr1, tr2))) end; - (type_expect env sarg ty, ty') + (type_expect env sarg ty, ty') in { exp_desc = arg.exp_desc; exp_loc = arg.exp_loc; @@ -590,68 +590,68 @@ let rec type_exp env sexp = try Env.lookup_class cl env with Not_found -> raise(Error(sexp.pexp_loc, Unbound_class cl)) in - begin match cl_typ.cty_new with - None -> - raise(Error(sexp.pexp_loc, Virtual_class cl)) + begin match cl_typ.cty_new with + None -> + raise(Error(sexp.pexp_loc, Virtual_class cl)) | Some ty -> { exp_desc = Texp_new cl_path; - exp_loc = sexp.pexp_loc; - exp_type = instance ty; + exp_loc = sexp.pexp_loc; + exp_type = instance ty; exp_env = env } end | Pexp_setinstvar (lab, snewval) -> begin try let (path, desc) = Env.lookup_value (Longident.Lident lab) env in match desc.val_kind with - Val_ivar Mutable -> - let newval = type_expect env snewval desc.val_type in - let (path_self, _) = + Val_ivar Mutable -> + let newval = type_expect env snewval desc.val_type in + let (path_self, _) = Env.lookup_value (Longident.Lident "*self*") env in { exp_desc = Texp_setinstvar(path_self, path, newval); exp_loc = sexp.pexp_loc; exp_type = instance Predef.type_unit; exp_env = env } - | Val_ivar _ -> - raise(Error(sexp.pexp_loc, Instance_variable_not_mutable lab)) - | _ -> + | Val_ivar _ -> + raise(Error(sexp.pexp_loc, Instance_variable_not_mutable lab)) + | _ -> raise(Error(sexp.pexp_loc, Unbound_instance_variable lab)) with - Not_found -> + Not_found -> raise(Error(sexp.pexp_loc, Unbound_instance_variable lab)) end | Pexp_override lst -> List.fold_right - (fun (lab, _) l -> - if List.exists ((=) lab) l then - raise(Error(sexp.pexp_loc, - Value_multiply_overridden lab)); - lab::l) - lst - []; + (fun (lab, _) l -> + if List.exists ((=) lab) l then + raise(Error(sexp.pexp_loc, + Value_multiply_overridden lab)); + lab::l) + lst + []; let (path_self, {val_type = self_ty}) = - try + try Env.lookup_value (Longident.Lident "*self*") env - with Not_found -> - raise(Error(sexp.pexp_loc, Outside_class)) + with Not_found -> + raise(Error(sexp.pexp_loc, Outside_class)) in let type_override (lab, snewval) = begin try let (path, desc) = Env.lookup_value (Longident.Lident lab) env in match desc.val_kind with - Val_ivar _ -> + Val_ivar _ -> (path, type_expect env snewval desc.val_type) - | _ -> + | _ -> raise(Error(sexp.pexp_loc, Unbound_instance_variable lab)) with - Not_found -> + Not_found -> raise(Error(sexp.pexp_loc, Unbound_instance_variable lab)) end in let modifs = List.map type_override lst in { exp_desc = Texp_override(path_self, modifs); - exp_loc = sexp.pexp_loc; - exp_type = self_ty; + exp_loc = sexp.pexp_loc; + exp_type = self_ty; exp_env = env } (* let obj = Oo.copy self in obj.x <- e; obj *) @@ -807,9 +807,9 @@ let type_method env self self_name meths sexp ty_expected = Env.enter_value name {val_type = self; val_kind = Val_self meths} env in ({ pat_desc = Tpat_alias (pattern, self_name); - pat_loc = Location.none; - pat_type = self }, - env) + pat_loc = Location.none; + pat_type = self }, + env) in let exp = type_expect_fun env sexp ty_expected in { exp_desc = Texp_function [(pattern, exp)]; diff --git a/typing/typecore.mli b/typing/typecore.mli index d3d210860d..cfa707bc2f 100644 --- a/typing/typecore.mli +++ b/typing/typecore.mli @@ -33,7 +33,7 @@ val type_expect: Env.t -> Parsetree.expression -> type_expr -> Typedtree.expression val type_exp: - Env.t -> Parsetree.expression -> Typedtree.expression + Env.t -> Parsetree.expression -> Typedtree.expression type error = Unbound_value of Longident.t diff --git a/typing/typemod.ml b/typing/typemod.ml index 593ece951a..de55679d86 100644 --- a/typing/typemod.ml +++ b/typing/typemod.ml @@ -293,11 +293,11 @@ let rec type_module env smod = with Includemod.Error msg -> raise(Error(sarg.pmod_loc, Not_included msg)) in let mty_appl = - try - let path = path_of_module arg in + try + let path = path_of_module arg in Subst.modtype (Subst.add_module param path Subst.identity) - mty_res - with Not_a_path -> + mty_res + with Not_a_path -> try Mtype.nondep_supertype (Env.add_module param arg.mod_type env) param mty_res @@ -394,7 +394,7 @@ and type_struct env sstr = :: str_rem, List.flatten (map_end - (fun (i, d, i', d', i'', d'', _) -> + (fun (i, d, i', d', i'', d'', _) -> [Tsig_class(i, d); Tsig_type(i', d'); Tsig_type(i'', d'')]) classes [sig_rem]), final_env) diff --git a/typing/types.ml b/typing/types.ml index b742ef6272..ab8dc46daf 100644 --- a/typing/types.ml +++ b/typing/types.ml @@ -54,9 +54,9 @@ type value_description = val_kind: value_kind } and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag (* Instance variable (mutable ?) *) + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag (* Instance variable (mutable ?) *) | Val_self of (Ident.t * type_expr) Meths.t ref (* Self *) | Val_anc of (string * Ident.t) list (* Ancestor *) diff --git a/typing/types.mli b/typing/types.mli index 292966e299..ea0665d512 100644 --- a/typing/types.mli +++ b/typing/types.mli @@ -52,9 +52,9 @@ type value_description = val_kind: value_kind } and value_kind = - Val_reg (* Regular value *) - | Val_prim of Primitive.description (* Primitive *) - | Val_ivar of mutable_flag (* Instance variable (mutable ?) *) + Val_reg (* Regular value *) + | Val_prim of Primitive.description (* Primitive *) + | Val_ivar of mutable_flag (* Instance variable (mutable ?) *) | Val_self of (Ident.t * type_expr) Meths.t ref (* Self *) | Val_anc of (string * Ident.t) list (* Ancestor *) |