Skip to content

Commit 4bd59d6

Browse files
committed
Demonstrate issue
1 parent 68e053b commit 4bd59d6

6 files changed

Lines changed: 103 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type t = unit
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let f (_ : Lib.t) = ()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type t = bool
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
let f (_ : Lib.t) = ()
2+
3+
(* The naming of this module is important: When the error reporting
4+
is running in a mode where it can load new cmis from disk, this
5+
module leads the compiler to try to load a cmi file [lib1_client.cmi].
6+
That's because the compiler tries to be smart about double-underscore
7+
paths, rewriting [Foo__Bar] to [Foo.Bar] when these names are aliases.
8+
*)
9+
module Lib1_client__X = struct
10+
type t = A
11+
end
12+
13+
module F (T : sig type t end) = struct
14+
type t = Lib1_client__X.t
15+
16+
let f (_ : T.t) = ()
17+
end
18+
19+
module _ = F (struct type t = T end)
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
File "lib2_client.ml", line 19, characters 11-36:
2+
19 | module _ = F (struct type t = T end)
3+
^^^^^^^^^^^^^^^^^^^^^^^^^
4+
Error: This functor has type "Fatal error: exception Persistent_env.Error(_)
5+
Raised at Persistent_env.error in file "typing/persistent_env.ml", line 32, characters 16-33
6+
Called from Persistent_env.acknowledge_pers_struct in file "typing/persistent_env.ml", lines 198-200, characters 2-4
7+
Called from Persistent_env.find_pers_struct in file "typing/persistent_env.ml", line 233, characters 17-64
8+
Called from Persistent_env.find in file "typing/persistent_env.ml", line 272, characters 6-55
9+
Called from Env.lookup_ident_module in file "typing/env.ml", line 2783, characters 16-51
10+
Called from Env.lookup_module_components in file "typing/env.ml", line 2864, characters 23-71
11+
Called from Env.lookup_structure_components in file "typing/env.ml", line 2876, characters 20-70
12+
Called from Env.lookup_dot_module in file "typing/env.ml", line 2965, characters 17-68
13+
Called from Env.lookup_module in file "typing/env.ml", line 2956, characters 23-66
14+
Called from Printtyp.rewrite_double_underscore_paths in file "typing/printtyp.ml", line 393, characters 12-50
15+
Called from Printtyp.rewrite_double_underscore_paths in file "typing/printtyp.ml", line 376, characters 10-47
16+
Called from Printtyp.tree_of_path in file "typing/printtyp.ml", line 433, characters 4-53
17+
Called from Printtyp.tree_of_typexp.pr_typ in file "typing/printtyp.ml", line 1193, characters 23-50
18+
Called from Printtyp.tree_of_type_decl in file "typing/printtyp.ml", line 1533, characters 12-34
19+
Called from Printtyp.tree_of_type_declaration in file "typing/printtyp.ml", line 1585, characters 13-38
20+
Called from Printtyp.trees_of_recursive_sigitem_group.display in file "typing/printtyp.ml", line 2037, characters 52-73
21+
Called from Stdlib__List.map in file "list.ml", line 83, characters 15-19
22+
Called from Stdlib__Fun.protect in file "fun.ml", line 34, characters 8-15
23+
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 39, characters 6-52
24+
Called from Printtyp.trees_of_recursive_sigitem_group in file "typing/printtyp.ml", line 2044, characters 6-62
25+
Called from Printtyp.tree_of_signature_rec.collect_trees_of_rec_group in file "typing/printtyp.ml", line 2028, characters 7-49
26+
Called from Stdlib__List.map in file "list.ml", line 86, characters 15-19
27+
Called from Printtyp.tree_of_signature.(fun) in file "typing/printtyp.ml", line 2019, characters 24-62
28+
Called from Printtyp.wrap_env in file "typing/printtyp.ml", line 1920, characters 13-22
29+
Called from Printtyp.tree_of_modtype in file "typing/printtyp.ml", line 1994, characters 27-47
30+
Called from Printtyp.wrap_env in file "typing/printtyp.ml", line 1920, characters 13-22
31+
Called from Printtyp.tree_of_modtype in file "typing/printtyp.ml", line 1999, characters 16-63
32+
Called from Printtyp.modtype in file "typing/printtyp.ml", line 2098, characters 50-71
33+
Called from Misc.Style.as_inline_code in file "utils/misc.ml", line 655, characters 4-17
34+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
35+
Called from Stdlib__Format.output_acc in file "format.ml", line 1393, characters 32-48
36+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
37+
Called from Stdlib__Format.output_acc in file "format.ml", line 1393, characters 32-48
38+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
39+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
40+
Called from Stdlib__Format.kfprintf.(fun) in file "format.ml", line 1444, characters 16-34
41+
Called from Stdlib__Format.output_acc in file "format.ml", line 1396, characters 32-48
42+
Called from Stdlib__Format.output_acc in file "format.ml", line 1396, characters 32-48
43+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
44+
Called from Stdlib__Format.output_acc in file "format.ml", line 1383, characters 4-20
45+
Called from Stdlib__Format.kfprintf.(fun) in file "format.ml", line 1444, characters 16-34
46+
Called from Location.print_updating_num_loc_lines in file "parsing/location.ml", line 145, characters 2-11
47+
Called from Optmaindriver.main in file "driver/optmaindriver.ml", line 136, characters 4-35
48+
Called from Optmain in file "driver/optmain.ml", line 2, characters 7-57
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
(* TEST
2+
subdirectories = "lib1 lib2";
3+
readonly_files = "lib1_client.ml lib2_client.ml";
4+
compile_only = "true";
5+
setup-ocamlopt.byte-build-env;
6+
7+
(* Set up the Lib modules that the client modules depend on *)
8+
all_modules = "lib1/lib.ml";
9+
ocamlopt.byte;
10+
all_modules = "lib2/lib.ml";
11+
ocamlopt.byte;
12+
13+
(* Compile Lib1_client against Lib1 *)
14+
flags = "-I lib1";
15+
all_modules = "lib1_client.ml";
16+
ocamlopt.byte;
17+
18+
(* Compile Lib2_client against Lib2 *)
19+
flags = "-I lib2";
20+
all_modules = "lib2_client.ml";
21+
ocamlopt_byte_exit_status = "2";
22+
ocamlopt.byte;
23+
check-ocamlopt.byte-output;
24+
*)
25+
26+
(* This test is a regression test. The bug is in the last step: the compiler crashes
27+
with an exception and backtrace instead of printing a useful error message. The
28+
issue is that the compiler was erroneously running in a mode where its error reporting
29+
is allowed to load cmi files from disk. This mode is undesirable because it means
30+
that the compiler can encounter new exceptions (e.g. that the new cmi file it loads
31+
is not consistent with other cmi files) while doing error reporting for the old
32+
exception.
33+
*)

0 commit comments

Comments
 (0)