diff options
| author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2003-11-19 03:28:00 +0000 |
|---|---|---|
| committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2003-11-19 03:28:00 +0000 |
| commit | b83eebce6ed692a3f1b4dfeca7a8444380ebc6d2 (patch) | |
| tree | 4ffbbcd03b3db9d46b6e3f56868f14592abad44c | |
| parent | 995aa942bdae103a4ccc1181029e2134255eed46 (diff) | |
| download | ocaml-b83eebce6ed692a3f1b4dfeca7a8444380ebc6d2.tar.gz | |
should read !meths only at end of typing
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/fastclass@5931 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
| -rw-r--r-- | typing/typeclass.ml | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/typing/typeclass.ml b/typing/typeclass.ml index 366ec055d0..eecc265d36 100644 --- a/typing/typeclass.ml +++ b/typing/typeclass.ml @@ -469,12 +469,15 @@ let rec class_field cl_num self_type meths vars raise(Error(loc, Method_type_mismatch (lab, trace))) end; let meth_expr = make_method cl_num expr in + (* backup variables for Pexp_override *) + let vars_local = !vars in let field = lazy begin let meth_type = Ctype.newty (Tarrow("", self_type, Ctype.instance ty, Cok)) in Ctype.raise_nongen_level (); + vars := vars_local; let texp = type_expect met_env meth_expr meth_type in Ctype.end_def (); Cf_meth (lab, texp) @@ -518,12 +521,14 @@ let rec class_field cl_num self_type meths vars | Pcf_init expr -> let expr = make_method cl_num expr in + let vars_local = !vars in let field = lazy begin Ctype.raise_nongen_level (); let meth_type = Ctype.newty (Tarrow ("", self_type, Ctype.instance Predef.type_unit, Cok)) in + vars := vars_local; let texp = type_expect met_env expr meth_type in Ctype.end_def (); Cf_init texp @@ -581,7 +586,6 @@ and class_structure cl_num final val_env met_env loc (spat, str) = {cty_self = public_self; cty_vars = Vars.map (function (id, mut, ty) -> (mut, ty)) !vars; cty_concr = concr_meths } in - let meths = Meths.map (function (id, ty) -> id) !meths in let methods = get_methods self_type in let priv_meths = List.filter (fun (_,kind,_) -> Btype.field_kind_repr kind <> Fpresent) @@ -611,6 +615,7 @@ and class_structure cl_num final val_env met_env loc (spat, str) = if !Clflags.principal then List.iter (fun (_,_,ty) -> Ctype.unify val_env ty (Ctype.newvar ())) methods; + let meths = Meths.map (function (id, ty) -> id) !meths in (* Check for private methods made public *) let pub_meths' = |
