Debian Codegraph @

testsuite/tests/tool-toplevel/known-bugs/broken_rec_in_show.ml

raw
1 (* TEST
2 expect;
3 *)
4
5 (* This is a known-bug file for use of 'rec' by the '#show' command,
6 to record known regressions from #7453 and #9094 *)
7
8 type t = T of t;;
9 [%%expect{|
10 type t = T of t
11 |}]
12 #show t;;
13 (* this output is CORRECT, it should not use nonrec *)
14 [%%expect{|
15 type t = T of t
16 |}];;
17
18 type nonrec s = Foo of t;;
19 [%%expect{|
20 type nonrec s = Foo of t
21 |}];;
22 #show s;;
23 (* this output is CORRECT, it elides the unnecessary nonrec keyword *)
24 [%%expect{|
25 type s = Foo of t
26 |}];;
27
28
29
30 module M : sig type t val x : t end = struct type t = int let x = 0 end;;
31 [%%expect{|
32 module M : sig type t val x : t end
33 |}];;
34 (* this output is CORRECT, it does not use 'rec' *)
35
36 module rec M : sig type t val x : M.t end = struct type t = int let x = 0 end;;
37 (* this output is CORRECT . *)
38 [%%expect{|
39 module rec M : sig type t val x : M.t end
40 |}];;
41 #show_module M;;
42 (* this output is CORRECT *)
43 [%%expect{|
44 module rec M : sig type t val x : M.t end
45 |}];;
46
47
48 (* Indirect recursion *)
49
50 type t
51 type f = [ `A of t ]
52 type t = X of u | Y of [ f | `B ] and u = Y of t;;
53
54 [%%expect{|
55 type t
56 type f = [ `A of t ]
57 type t = X of u | Y of [ `A of t/2 | `B ]
58 and u = Y of t
59 |}];;
60
61 #show t;;
62 (* this output is PARTIAL: t is mutually recursive with u *)
63 [%%expect{|
64 type nonrec t = X of u | Y of [ `A of t/2 | `B ]
65 |}];;
66
67
68 module rec M: sig type t = X of N.t end = M
69 and N: sig type t = X of M.t end = N
70
71 [%%expect{|
72 module rec M : sig type t = X of N.t end
73 and N : sig type t = X of M.t end
74 |}];;
75
76 (* this output is PARTIAL: M is mutually recursive with N *)
77 #show M;;
78 [%%expect{|
79 module M : sig type t = X of N.t end
80 |}];;