diff options
author | maranget <Luc.Maranget@inria.fr> | 2017-11-28 17:44:09 +0100 |
---|---|---|
committer | maranget <Luc.Maranget@inria.fr> | 2017-11-28 17:44:09 +0100 |
commit | ec87d13c371ebb6fac6e301cd089df70b735222e (patch) | |
tree | 136788d227a3f4989b3639fedad799729d4f6368 | |
parent | 852b595ff3b84788c31338053488a7ed5944b431 (diff) | |
download | ocaml-ec87d13c371ebb6fac6e301cd089df70b735222e.tar.gz |
Re-enable pattern-matching warnings + add reference file for compilers.
-rw-r--r-- | testsuite/tests/basic-more/morematch.compilers.reference | 30 | ||||
-rw-r--r-- | testsuite/tests/basic-more/morematch.ml | 63 |
2 files changed, 44 insertions, 49 deletions
diff --git a/testsuite/tests/basic-more/morematch.compilers.reference b/testsuite/tests/basic-more/morematch.compilers.reference new file mode 100644 index 0000000000..7f077dd6ff --- /dev/null +++ b/testsuite/tests/basic-more/morematch.compilers.reference @@ -0,0 +1,30 @@ +File "morematch.ml", line 1050, characters 8-65: +Warning 8: this pattern-matching is not exhaustive. +Here is an example of a case that is not matched: +(A `D|B (`B, (`A|`C))) +File "morematch.ml", line 67, characters 2-5: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 68, characters 2-3: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 219, characters 33-47: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 388, characters 2-15: +Warning 11: this match case is unused. +File "morematch.ml", line 401, characters 2-20: +Warning 11: this match case is unused. +File "morematch.ml", line 402, characters 2-16: +Warning 11: this match case is unused. +File "morematch.ml", line 403, characters 2-29: +Warning 11: this match case is unused. +File "morematch.ml", line 413, characters 5-12: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 432, characters 43-44: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 455, characters 7-8: +Warning 12: this sub-pattern is unused. +File "morematch.ml", line 456, characters 2-7: +Warning 11: this match case is unused. +File "morematch.ml", line 1084, characters 5-51: +Warning 11: this match case is unused. +File "morematch.ml", line 1086, characters 5-51: +Warning 11: this match case is unused. diff --git a/testsuite/tests/basic-more/morematch.ml b/testsuite/tests/basic-more/morematch.ml index 5e4be98ad9..99d0d61dfd 100644 --- a/testsuite/tests/basic-more/morematch.ml +++ b/testsuite/tests/basic-more/morematch.ml @@ -8,17 +8,6 @@ (* While compiling the following messages are normal: *) (**************************************************************) -(* -File "morematch.ml", line 38, characters 10-93: -Warning: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -0 -File "morematch.ml", line 376, characters 2-15: -Warning: this match case is unused. -File "morematch.ml", line 443, characters 2-7: -Warning: this match case is unused. -*) - let test msg f arg r = if f arg <> r then begin prerr_endline msg ; @@ -78,18 +67,13 @@ let g x= match x with | 4|5|7 -> 100 | 7 | 8 -> 6 | 9 -> 7 -| _ -> 8 [@@ocaml.warning "-12"];; +| _ -> 8 +;; + test "quatre" g 4 4 ; test "quatre" g 7 100 ; () ;; -(* -File "morematch.ml", line 73, characters 2-5: -Warning U: this sub-pattern is unused. -File "morematch.ml", line 74, characters 2-3: -Warning U: this sub-pattern is unused. -*) - let h x = match x with (1,1) -> 1 @@ -233,7 +217,6 @@ test "foo1" f (1,2) (-1) let f = function (([]|[_]) as x)|(_::([] as x))|(_::_::x) -> x - [@@ocaml.warning "-12"] ;; test "zob" f [] [] ; @@ -402,7 +385,7 @@ let yaya = function | A,_,_ -> 1 | _,A,_ -> 2 | B,B,_ -> 3 -| A,_,(100|103) -> 5 [@@ocaml.warning "-11"] +| A,_,(100|103) -> 5 ;; test "yaya" yaya (A,A,0) 1 ; @@ -410,7 +393,7 @@ test "yaya" yaya (B,A,0) 2 ; test "yaya" yaya (B,B,100) 3 ; () ;; -(* + let yoyo = function | [],_,_ -> 1 | _,[],_ -> 2 @@ -436,7 +419,7 @@ test "youyou" youyou 100 1 ; test "youyou" youyou 101 2 ; test "youyou" youyou 1000 3 ;; -*) + type autre = | C | D | E of autre | F of autre * autre | H of autre | I | J | K of string @@ -449,12 +432,10 @@ let rec autre = function | (J,J,((C|D) as x |E x|F (_,x))) | (J,_,((C|J) as x)) -> autre (x,x,x) | (J, J, (I|H _|K _)) -> 9 | I,_,_ -> 6 -| E _,_,_ -> 7 [@@ocaml.warning "-12"] +| E _,_,_ -> 7 ;; -(* -File "morematch.ml", line 437, characters 43-44: -Warning U: this sub-pattern is unused. -*) + + test "autre" autre (J,J,F (D,D)) 3 ; test "autre" autre (J,J,D) 3 ; test "autre" autre (J,J,I) 9 ; @@ -472,14 +453,9 @@ let xyz = function | YB,YB,_ -> 3 | ((YB|YC), (YB|YC), (X|Y|Z|V _|T _)) -> 6 | _,_,(X|U _) -> 8 -| _,_,Y -> 5 [@@ocaml.warning "-11-12"] +| _,_,Y -> 5 ;; -(* -File "morematch.ml", line 459, characters 7-8: -Warning U: this sub-pattern is unused. -File "morematch.ml", line 460, characters 2-7: -Warning U: this match case is unused. -*) + test "xyz" xyz (YC,YC,X) 6 ; test "xyz" xyz (YC,YB,U X) 8 ; test "xyz" xyz (YB,YC,X) 6 ; () @@ -1069,18 +1045,12 @@ test "seb" seb ((0,Uout),Uin) 2 ; false (in Switch) *) -(* -File "morematch.ml", line 1060, characters 8-65: -Warning: this pattern-matching is not exhaustive. -Here is an example of a value that is not matched: -A `D -*) type ('a, 'b) t_j = A of 'a | B of 'b * 'a | C let f = function | A (`A|`C) -> 0 | B (`B,`D) -> 1 - | C -> 2 [@@ocaml.warning "-8"] + | C -> 2 let g x = try f x with Match_failure _ -> 3 @@ -1114,13 +1084,8 @@ let f = function | _, _, _, _, _, A, _, _, _, _, B, _, _, _, _, _ -> "11" | B, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "12" | _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _ -> "13" -[@@ocaml.warning "-11"] -(* -File "morematch.ml", line 1094, characters 5-51: -Warning: this match case is unused. -File "morematch.ml", line 1096, characters 5-51: -Warning: this match case is unused. -*) + + let _ = test "luc" f (B, A, A, A, A, A, A, A, A, A, A, B, A, A, A, A) "10" ; test "luc" f (B, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A) "12" ; |