summaryrefslogtreecommitdiff
path: root/testsuite/tests/typing-polyvariants-bugs/pr8575.ml
blob: 1cb1bc3b38aee45acbaead28148892044d60cadc (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
(* TEST
 expect;
*)

module A = struct type t = A | B let x = B end;;
[%%expect{|
module A : sig type t = A | B val x : t end
|}]

let test () =
  match A.x with
  | A as a -> `A_t a
  | B when false -> `Onoes
  | B -> if Random.bool () then `Onoes else `A_t B;;
[%%expect{|
val test : unit -> [> `A_t of A.t | `Onoes ] = <fun>
|}, Principal{|
Line 5, characters 49-50:
5 |   | B -> if Random.bool () then `Onoes else `A_t B;;
                                                     ^
Warning 18 [not-principal]: this type-based constructor disambiguation is not principal.

val test : unit -> [> `A_t of A.t | `Onoes ] = <fun>
|}]

let test () =
  match A.x with
  | B when false -> `Onoes
  | A as a -> `A_t a
  | B -> if Random.bool () then `Onoes else `A_t B;;
[%%expect{|
val test : unit -> [> `A_t of A.t | `Onoes ] = <fun>
|}, Principal{|
Line 5, characters 49-50:
5 |   | B -> if Random.bool () then `Onoes else `A_t B;;
                                                     ^
Warning 18 [not-principal]: this type-based constructor disambiguation is not principal.

val test : unit -> [> `A_t of A.t | `Onoes ] = <fun>
|}]