summaryrefslogtreecommitdiff
path: root/testsuite/tests/tool-toplevel/known-bugs/broken_rec_in_show.ml
blob: d496f06be48c73cfe976abde84fc3ca6cd6c5849 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(* TEST
 expect;
*)

(* This is a known-bug file for use of 'rec' by the '#show' command,
   to record known regressions from #7453 and #9094 *)

type t = T of t;;
[%%expect{|
type t = T of t
|}]
#show t;;
(* this output is CORRECT, it should not use nonrec *)
[%%expect{|
type t = T of t
|}];;

type nonrec s = Foo of t;;
[%%expect{|
type nonrec s = Foo of t
|}];;
#show s;;
(* this output is CORRECT, it elides the unnecessary nonrec keyword *)
[%%expect{|
type s = Foo of t
|}];;



module M : sig type t val x : t end = struct type t = int let x = 0 end;;
[%%expect{|
module M : sig type t val x : t end
|}];;
(* this output is CORRECT, it does not use 'rec' *)

module rec M : sig type t val x : M.t end = struct type t = int let x = 0 end;;
(* this output is CORRECT . *)
[%%expect{|
module rec M : sig type t val x : M.t end
|}];;
#show_module M;;
(* this output is CORRECT *)
[%%expect{|
module rec M : sig type t val x : M.t end
|}];;


(* Indirect recursion *)

type t
type f = [ `A of t ]
type t = X of u | Y of [ f | `B ]  and u = Y of t;;

[%%expect{|
type t
type f = [ `A of t ]
type t = X of u | Y of [ `A of t/2 | `B ]
and u = Y of t
|}];;

#show t;;
(* this output is PARTIAL: t is mutually recursive with u *)
[%%expect{|
type nonrec t = X of u | Y of [ `A of t/2 | `B ]
|}];;


module rec M: sig type t = X of N.t end = M
and N: sig type t = X of M.t end = N

[%%expect{|
module rec M : sig type t = X of N.t end
and N : sig type t = X of M.t end
|}];;

(* this output is PARTIAL: M is mutually recursive with N *)
#show M;;
[%%expect{|
module M : sig type t = X of N.t end
|}];;