From 692b92794da04de36f37bd855903f0afeb2adc22 Mon Sep 17 00:00:00 2001 From: ZAN DoYe Date: Wed, 25 Mar 2020 09:58:22 +0800 Subject: [PATCH] make the #use_output directive compatible with ocaml >= 4.02 --- src/lib/uTop.ml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/uTop.ml b/src/lib/uTop.ml index 13533d9..94ce8da 100644 --- a/src/lib/uTop.ml +++ b/src/lib/uTop.ml @@ -748,9 +748,16 @@ let () = +-----------------------------------------------------------------+ *) +let try_finally ~always work= +#if OCAML_VERSION >= (4, 08, 0) + Misc.try_finally ~always work +#else + Misc.try_finally work always +#endif + let use_output command = let fn = Filename.temp_file "ocaml" "_toploop.ml" in - Misc.try_finally ~always:(fun () -> + try_finally ~always:(fun () -> try Sys.remove fn with Sys_error _ -> ()) (fun () -> match