Reflecting commit 14976 on version/4.02:

PR#6211: in toplevel interactive use, bad interaction between uncaught
exceptions and multiple bindings of the form "let x = a let y = b;;".


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14977 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 2014-06-09 15:14:41 +00:00
parent 7cb9d0d84e
commit bb83542732
2 changed files with 11 additions and 5 deletions

View File

@ -187,6 +187,9 @@ Bug fixes:
(Jacques-Pascal Deplaix)
- PR#6194: Incorrect unused warning with first-class modules in patterns
(Jacques Garrigue, report by Markus Mottl and Leo White)
- PR#6211: in toplevel interactive use, bad interaction between uncaught
exceptions and multiple bindings of the form "let x = a let y = b;;".
(Xavier Leroy)
- PR#6216: inlining of GADT matches generates invalid assembly
(Xavier Leroy and Alain Frisch, report by Mark Shinwell)
- PR#6233: out-of-bounds exceptions lose their locations on ARM, PowerPC

View File

@ -31,17 +31,18 @@ type directive_fun =
(* The table of toplevel value bindings and its accessors *)
let toplevel_value_bindings =
(Hashtbl.create 37 : (string, Obj.t) Hashtbl.t)
module StringMap = Map.Make(String)
let toplevel_value_bindings : Obj.t StringMap.t ref = ref StringMap.empty
let getvalue name =
try
Hashtbl.find toplevel_value_bindings name
StringMap.find name !toplevel_value_bindings
with Not_found ->
fatal_error (name ^ " unbound at toplevel")
let setvalue name v =
Hashtbl.replace toplevel_value_bindings name v
toplevel_value_bindings := StringMap.add name v !toplevel_value_bindings
(* Return the value referred to by a path *)
@ -52,7 +53,7 @@ let rec eval_path = function
else begin
let name = Translmod.toplevel_name id in
try
Hashtbl.find toplevel_value_bindings name
StringMap.find name !toplevel_value_bindings
with Not_found ->
raise (Symtable.Error(Symtable.Undefined_global name))
end
@ -150,6 +151,7 @@ let load_lambda ppf lam =
Symtable.patch_object code reloc;
Symtable.check_global_initialized reloc;
Symtable.update_global_table();
let initial_bindings = !toplevel_value_bindings in
try
may_trace := true;
let retval = (Meta.reify_bytecode code code_size) () in
@ -165,6 +167,7 @@ let load_lambda ppf lam =
Meta.static_release_bytecode code code_size;
Meta.static_free code;
end;
toplevel_value_bindings := initial_bindings; (* PR#6211 *)
Symtable.restore_state initial_symtable;
Exception x