readable failure messages should not be debug-mode-only features

This commit is contained in:
Gabriel Scherer 2019-08-19 09:14:26 +02:00 committed by Nathanaël Courant
parent 3083bd1fe9
commit 70655bf514
2 changed files with 9 additions and 12 deletions

View File

@ -114,15 +114,13 @@ let decompose get_module_data env { txt = lident; loc } =
let lookup object_name ~env_name object_env { txt = str; loc } =
try snd (SMap.find str object_env)
with Not_found ->
if debug
then
Format.eprintf
"%a@.%s not found in %s: %s@."
Location.print_loc
loc
(String.capitalize_ascii object_name)
env_name
str;
Format.eprintf
"%a@.%s not found in %s: %s@."
Location.print_loc
loc
(String.capitalize_ascii object_name)
env_name
str;
raise Not_found
let rec env_get_module env ({ loc; _ } as lid) =

View File

@ -169,8 +169,7 @@ and eval_expr prims env expr =
let loc = expr.pexp_loc in
(match fexpr loc l with
| None ->
if debug
then Format.eprintf "%a@.F-expr failure.@." Location.print_loc loc;
Format.eprintf "%a@.F-expr failure.@." Location.print_loc loc;
assert false
| Some expr -> eval_expr prims env expr)
| func_value ->
@ -761,7 +760,7 @@ and eval_structitem prims env it =
with Not_found ->
ptr @@ Prim
(fun _ ->
if debug then Format.eprintf "%a@." Location.print_loc loc;
Format.eprintf "%a@." Location.print_loc loc;
failwith ("Unimplemented primitive " ^ prim_name))
in
env_set_value name prim env