Merge pull request #339 from emillon/build-on-4.12

Fix build on 4.12
This commit is contained in:
Etienne Millon 2021-01-06 20:44:17 +01:00 committed by GitHub
commit 5c55cb60a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 5 deletions

View File

@ -589,15 +589,21 @@ let rewrite_str_item pstr_item tstr_item =
| _ -> | _ ->
pstr_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 = let rewrite phrase =
match phrase with match phrase with
| Parsetree.Ptop_def pstr -> | Parsetree.Ptop_def pstr ->
if (UTop.get_auto_run_lwt () || UTop.get_auto_run_async ()) && List.exists is_eval pstr then 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 = type_structure !Toploop.toplevel_env pstr in
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
Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr.Typedtree.str_items) Parsetree.Ptop_def (List.map2 rewrite_str_item pstr tstr.Typedtree.str_items)
else else
phrase phrase