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
97
98
99
100
101
102
103
|
(* TEST
flags = "-w +A";
expect;
*)
let () = try () with Invalid_argument "Any" -> ();;
[%%expect{|
Line 1, characters 38-43:
1 | let () = try () with Invalid_argument "Any" -> ();;
^^^^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
|}];;
let () = try () with Match_failure ("Any",_,_) -> ();;
[%%expect{|
Line 1, characters 35-46:
1 | let () = try () with Match_failure ("Any",_,_) -> ();;
^^^^^^^^^^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
|}];;
let () = try () with Match_failure (_,0,_) -> ();;
[%%expect{|
Line 1, characters 35-42:
1 | let () = try () with Match_failure (_,0,_) -> ();;
^^^^^^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
|}];;
type t =
| Warn of string [@ocaml.warn_on_literal_pattern]
| Without_warning of string
| Warn' of nativeint [@ocaml.warn_on_literal_pattern]
| Deep of (string * int) list [@ocaml.warn_on_literal_pattern];;
[%%expect{|
type t =
Warn of string
| Without_warning of string
| Warn' of nativeint
| Deep of (string * int) list
|}];;
let f = function
| Warn "anything" -> ()
| Warn _ | Warn' _ | Without_warning _ | Deep _ -> ();;
[%%expect{|
Line 2, characters 7-17:
2 | | Warn "anything" -> ()
^^^^^^^^^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
val f : t -> unit = <fun>
|}];;
let g = function
| Warn' 0n -> ()
| Warn _ | Warn' _ | Without_warning _ | Deep _ -> ();;
[%%expect{|
Line 2, characters 8-10:
2 | | Warn' 0n -> ()
^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
val g : t -> unit = <fun>
|}];;
let h = function
| Without_warning "outside" -> ()
| Warn _ | Warn' _ | Without_warning _ | Deep _ -> ();;
[%%expect{|
val h : t -> unit = <fun>
|}];;
let i = function
| Deep (_ :: _ :: _ :: _) -> ()
| Warn _ | Warn' _ | Without_warning _ | Deep _ -> ();;
[%%expect{|
val i : t -> unit = <fun>
|}];;
let j = function
| Deep (_ :: _ :: ("deep",_) :: _) -> ()
| Warn _ | Warn' _ | Without_warning _ | Deep _ -> ();;
[%%expect{|
Line 2, characters 7-34:
2 | | Deep (_ :: _ :: ("deep",_) :: _) -> ()
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 52 [fragile-literal-pattern]: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (see manual section 13.5.3)
val j : t -> unit = <fun>
|}];;
|