Skip to content

Commit f91dfcd

Browse files
Merge pull request #322 from emillon/remove-patch-env
Do not use patch_env anymore
2 parents a7a5ab4 + 751045d commit f91dfcd

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
#### Fixed
1010

11+
- Use the same output as the normal toplevel. Mdx used to carry an unsafe patch
12+
to work around a bug fixed in OCaml 4.06 and that patch would change the
13+
printed types in some corner cases. (#322, @emillon)
14+
1115
#### Removed
1216

1317
- Dropped compatibility with older OCaml versions. The minimal supported range

lib/top/mdx_top.ml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -636,35 +636,6 @@ let verbose t =
636636
let silent t =
637637
add_directive ~name:"silent" ~doc:"Be silent" (`Bool (fun x -> t.silent <- x))
638638

639-
(* BLACK MAGIC: patch field of a module at runtime *)
640-
let monkey_patch (type a) (m : a) (type b) (prj : unit -> b) (v : b) =
641-
let m = Obj.repr m in
642-
let v = Obj.repr v in
643-
let v' = Obj.repr (prj ()) in
644-
if v' == v then ()
645-
else
646-
try
647-
for i = 0 to Obj.size m - 1 do
648-
if Obj.field m i == v' then (
649-
Obj.set_field m i v;
650-
if Obj.repr (prj ()) == v then raise Exit;
651-
Obj.set_field m i v')
652-
done;
653-
invalid_arg "monkey_patch: field not found"
654-
with Exit -> ()
655-
656-
let patch_env () =
657-
let module M = struct
658-
module type T = module type of Env
659-
660-
let field () = Env.without_cmis
661-
662-
let replacement f x = f x
663-
664-
let () = monkey_patch (module Env : T) field replacement
665-
end in
666-
()
667-
668639
let protect f arg =
669640
try
670641
let _ = f arg in
@@ -703,7 +674,6 @@ let init ~verbose:v ~silent:s ~verbose_findlib ~directives ~packages ~predicates
703674
Mdx.Compat.init_path ();
704675
Toploop.toplevel_env := Compmisc.initial_env ();
705676
Sys.interactive := false;
706-
patch_env ();
707677
List.iter
708678
(function
709679
| Directory path -> Topdirs.dir_directory path

0 commit comments

Comments
 (0)