From e31656e72559c94bec144434f9d68e3ae801b14e Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Fri, 30 Oct 2020 16:22:14 +0100 Subject: [PATCH] Fix build on 4.12 On 4.12, `Typemod.type_structure` does not take a location argument anymore (see ocaml/ocaml#9974). This fixes the build with the 4.12 branch. --- src/lib/uTop_main.ml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/uTop_main.ml b/src/lib/uTop_main.ml index 3c6e83c..3d9abee 100644 --- a/src/lib/uTop_main.ml +++ b/src/lib/uTop_main.ml @@ -589,15 +589,21 @@ let rewrite_str_item pstr_item tstr_item = | _ -> pstr_item +let type_structure env pstr = +#if OCAML_VERSION >= (4, 12, 0) + let tstr, _, _, _ = Typemod.type_structure env pstr in +#elif OCAML_VERSION >= (4, 08, 0) + let tstr, _, _, _ = Typemod.type_structure env pstr Location.none in +#else + let tstr, _, _ = Typemod.type_structure env pstr Location.none in +#endif + tstr + let rewrite phrase = match phrase with | Parsetree.Ptop_def pstr -> if (UTop.get_auto_run_lwt () || UTop.get_auto_run_async ()) && List.exists is_eval pstr then -#if OCAML_VERSION >= (4, 08, 0) - let tstr, _, _, _ = Typemod.type_structure !Toploop.toplevel_env pstr Location.none in -#else - let tstr, _, _ = Typemod.type_structure !Toploop.toplevel_env pstr Location.none in -#endif + let tstr = type_structure !Toploop.toplevel_env pstr in Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr.Typedtree.str_items) else phrase