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.
This commit is contained in:
Etienne Millon 2020-10-30 16:22:14 +01:00
parent 7bc5117d34
commit e31656e725
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
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