diff options
author | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2011-12-27 07:02:11 +0000 |
---|---|---|
committer | Jacques Garrigue <garrigue at math.nagoya-u.ac.jp> | 2011-12-27 07:02:11 +0000 |
commit | c663cf699740640cbefdab45b8b86deace71368b (patch) | |
tree | 9860ba75dabce727f6c56ee6b5f23db492bb9743 | |
parent | bc8d8e957e9ac0679280b14730351a3abfd094c8 (diff) |
fix PR#5445
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@11956 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | typing/typecore.ml | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/typing/typecore.ml b/typing/typecore.ml index 9deb1be40..48caaa7ff 100644 --- a/typing/typecore.ml +++ b/typing/typecore.ml @@ -2692,6 +2692,17 @@ let type_binding env rec_flag spat_sexp_list scope = (* Typing of toplevel expressions *) +let lookup_ident_type env sexp = + (* Special case for keeping type variables when looking-up a variable *) + match sexp.pexp_desc with + Pexp_ident lid -> + let (path, desc) = Env.lookup_value lid env in + begin match desc.val_kind with + Val_reg | Val_prim _ -> desc.val_type + | Val_ivar _ | Val_self _ | Val_anc _ | Val_unbound -> raise Not_found + end + | _ -> raise Not_found + let type_expression env sexp = Typetexp.reset_type_variables(); begin_def(); @@ -2699,7 +2710,8 @@ let type_expression env sexp = end_def(); if is_nonexpansive exp then generalize exp.exp_type else generalize_expansive env exp.exp_type; - exp + try {exp with exp_type = lookup_ident_type env sexp } + with Not_found -> exp (* Error report *) |