summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-warnings/pr6872.ml
blob: b3d8b803a93e1909f3657506767d34999d3cbc83 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(* TEST
 flags = " -w +A -strict-sequence ";
 expect;
*)

(* Ignore OCAMLRUNPARAM=b to be reproducible *)
Printexc.record_backtrace false
[%%expect {|
- : unit = ()
|}]
;;

exception A
[%%expect {|
exception A
|}]
;;

type a = A
[%%expect {|
type a = A
|}]
;;

A
[%%expect {|
Line 1, characters 0-1:
1 | A
    ^
Warning 41 [ambiguous-name]: A belongs to several types: a exn
The first one was selected. Please disambiguate if this is wrong.

- : a = A
|}]
;;

raise A
[%%expect {|
Line 1, characters 6-7:
1 | raise A
          ^
Warning 42 [disambiguated-name]: this use of A relies on type-directed disambiguation,
it will not compile with OCaml 4.00 or earlier.

Exception: A.
|}]
;;

fun (A : a) -> ()
[%%expect {|
- : a -> unit = <fun>
|}]
;;

function Not_found -> 1 | A -> 2 | _ -> 3
[%%expect {|
Line 1, characters 26-27:
1 | function Not_found -> 1 | A -> 2 | _ -> 3
                              ^
Warning 42 [disambiguated-name]: this use of A relies on type-directed disambiguation,
it will not compile with OCaml 4.00 or earlier.

- : exn -> int = <fun>
|}, Principal{|
Line 1, characters 26-27:
1 | function Not_found -> 1 | A -> 2 | _ -> 3
                              ^
Warning 18 [not-principal]: this type-based constructor disambiguation is not principal.

Line 1, characters 26-27:
1 | function Not_found -> 1 | A -> 2 | _ -> 3
                              ^
Warning 42 [disambiguated-name]: this use of A relies on type-directed disambiguation,
it will not compile with OCaml 4.00 or earlier.

- : exn -> int = <fun>
|}]
;;

try raise A with A -> 2
[%%expect {|
Line 1, characters 10-11:
1 | try raise A with A -> 2
              ^
Warning 42 [disambiguated-name]: this use of A relies on type-directed disambiguation,
it will not compile with OCaml 4.00 or earlier.

Line 1, characters 17-18:
1 | try raise A with A -> 2
                     ^
Warning 42 [disambiguated-name]: this use of A relies on type-directed disambiguation,
it will not compile with OCaml 4.00 or earlier.

- : int = 2
|}]
;;