summaryrefslogtreecommitdiff
path: root/testsuite/tests/match-exception-warnings/reachability.ml
blob: 9549c50eaa61d64d2893b6e7c52b791ded02ee11 (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
(* TEST
 expect;
*)

let f x =
  match x with
  | _ -> ()
  | exception _ -> .
;;

[%%expect{|
Line 4, characters 14-15:
4 |   | exception _ -> .
                  ^
Error: This match case could not be refuted.
       Here is an example of a value that would reach it: _
|}]
;;

let f x =
  match x with
  | _ -> ()
  | None | exception _ -> .
;;

[%%expect{|
Line 4, characters 21-22:
4 |   | None | exception _ -> .
                         ^
Error: This match case could not be refuted.
       Here is an example of a value that would reach it: _
|}]
;;


let f x =
  match x with
  | _ -> ()
  | exception Not_found | None -> .
;;


[%%expect{|
Line 4, characters 14-23:
4 |   | exception Not_found | None -> .
                  ^^^^^^^^^
Error: This match case could not be refuted.
       Here is an example of a value that would reach it: Not_found
|}]
;;

let f x =
  match x with
  | _ | exception _ -> ()
  | exception Not_found -> .
;;

[%%expect{|
val f : 'a -> unit = <fun>
|}]
;;