diff options
-rw-r--r-- | Changes | 3 | ||||
-rw-r--r-- | toplevel/toploop.ml | 13 |
2 files changed, 11 insertions, 5 deletions
@@ -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 diff --git a/toplevel/toploop.ml b/toplevel/toploop.ml index 152f114f8..2261dccbc 100644 --- a/toplevel/toploop.ml +++ b/toplevel/toploop.ml @@ -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 |