From 6a518303050713e5d6e7be20b98c5ee44148c85d Mon Sep 17 00:00:00 2001 From: Christopher Zimmermann Date: Mon, 7 Oct 2019 14:07:11 +0200 Subject: [PATCH] Don't use raise_with_backtrace in backward-compatible Fun.protect --- src/core/mkshims.ml | 4 ++-- src/core/stdlib/fun.ml | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/core/mkshims.ml b/src/core/mkshims.ml index 811f2fe4..447ae058 100644 --- a/src/core/mkshims.ml +++ b/src/core/mkshims.ml @@ -58,8 +58,8 @@ let shims_fun_mli_pre_408 = (** This is the [Fun] module distributed with the OCaml Core system. It is linked with containers in case the installed OCaml system does not provide a compatible [Fun] module. - It is the an unmodified version of [Fun] as shipped with the OCaml core - system. + It is the a slightly modified version of [Fun] as shipped with the OCaml + core system. *) " ^ read_file "stdlib/fun.mli" diff --git a/src/core/stdlib/fun.ml b/src/core/stdlib/fun.ml index 247f107e..db48d060 100644 --- a/src/core/stdlib/fun.ml +++ b/src/core/stdlib/fun.ml @@ -23,12 +23,10 @@ exception Finally_raised of exn let protect ~(finally : unit -> unit) work = let finally_no_exn () = try finally () with e -> - let bt = Printexc.get_raw_backtrace () in - Printexc.raise_with_backtrace (Finally_raised e) bt + raise (Finally_raised e) in match work () with | result -> finally_no_exn () ; result | exception work_exn -> - let work_bt = Printexc.get_raw_backtrace () in finally_no_exn () ; - Printexc.raise_with_backtrace work_exn work_bt + raise work_exn