diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-11-10 12:54:59 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-17 05:11:38 -0500 |
commit | 29086749b8d6bec162414fbec8921df0382d0627 (patch) | |
tree | b21134cf637ad64032dc41f3578dc1ba3c783086 /testsuite/tests/pmcheck | |
parent | 4cec6cf284d65449bbdaf015fadd7768770ec52b (diff) | |
download | haskell-29086749b8d6bec162414fbec8921df0382d0627.tar.gz |
Pmc: Don't case split on wildcard matches (#20642)
Since 8.10, when formatting a pattern match warning, we'd case split on a
wildcard match such as
```hs
foo :: [a] -> [a]
foo [] = []
foo xs = ys
where
(_, ys@(_:_)) = splitAt 0 xs
-- Pattern match(es) are non-exhaustive
-- In a pattern binding:
-- Patterns not matched:
-- ([], [])
-- ((_:_), [])
```
But that's quite verbose and distracts from which part of the pattern was
actually the inexhaustive one. We'd prefer a wildcard for the first pair
component here, like it used to be in GHC 8.8.
On the other hand, case splitting is pretty handy for `-XEmptyCase` to know the
different constructors we could've matched on:
```hs
f :: Bool -> ()
f x = case x of {}
-- Pattern match(es) are non-exhaustive
-- In a pattern binding:
-- Patterns not matched:
-- False
-- True
```
The solution is to communicate that we want a top-level case split to
`generateInhabitingPatterns` for `-XEmptyCase`, which is exactly what
this patch arranges. Details in `Note [Case split inhabiting patterns]`.
Fixes #20642.
Diffstat (limited to 'testsuite/tests/pmcheck')
28 files changed, 134 insertions, 112 deletions
diff --git a/testsuite/tests/pmcheck/complete_sigs/T18960b.stderr b/testsuite/tests/pmcheck/complete_sigs/T18960b.stderr index fd27f0853e..6148f75a07 100644 --- a/testsuite/tests/pmcheck/complete_sigs/T18960b.stderr +++ b/testsuite/tests/pmcheck/complete_sigs/T18960b.stderr @@ -5,8 +5,8 @@ T18960b.hs:11:7: warning: [-Wincomplete-patterns (in -Wextra)] Patterns of type ‘((), String)’ not matched: (_, _) P ((), []) - P ((), [p]) where p is not one of {'h'} - P ((), (p:_:_)) where p is not one of {'h'} + P ((), (p:_)) where p is not one of {'h'} + P ((), ['h']) ... T18960b.hs:18:7: warning: [-Wincomplete-patterns (in -Wextra)] @@ -15,6 +15,6 @@ T18960b.hs:18:7: warning: [-Wincomplete-patterns (in -Wextra)] Patterns of type ‘((), String)’ not matched: (_, _) P ((), []) - P ((), [p]) where p is not one of {'h'} - P ((), (p:_:_)) where p is not one of {'h'} + P ((), (p:_)) where p is not one of {'h'} + P ((), ['h']) ... diff --git a/testsuite/tests/pmcheck/complete_sigs/completesig06.stderr b/testsuite/tests/pmcheck/complete_sigs/completesig06.stderr index b993966789..2d58080949 100644 --- a/testsuite/tests/pmcheck/complete_sigs/completesig06.stderr +++ b/testsuite/tests/pmcheck/complete_sigs/completesig06.stderr @@ -1,29 +1,29 @@ completesig06.hs:13:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In an equation for ‘m1’: Patterns of type ‘T’ not matched: B + In an equation for ‘m1’: Patterns of type ‘T’ not matched: B completesig06.hs:16:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In an equation for ‘m2’: Patterns of type ‘T’ not matched: A + In an equation for ‘m2’: Patterns of type ‘T’ not matched: A completesig06.hs:20:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘m3’: - Patterns of type ‘T’ not matched: + Patterns of type ‘T’ not matched: A B completesig06.hs:23:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘m4’: - Patterns of type ‘T’, ‘S’ not matched: + Patterns of type ‘T’, ‘S’ not matched: A D B D completesig06.hs:29:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘m5’: - Patterns of type ‘T’, ‘S’ not matched: - A D - B D + Patterns of type ‘T’, ‘S’ not matched: + A _ + B _ diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr index e3794c0405..cd00f26f8b 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase001.stderr @@ -1,15 +1,15 @@ EmptyCase001.hs:9:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘Int’ not matched: _ + In a case alternative: Patterns of type ‘Int’ not matched: _ EmptyCase001.hs:14:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘String’ not matched: + Patterns of type ‘String’ not matched: [] (_:_) EmptyCase001.hs:18:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘Char’ not matched: _ + In a case alternative: Patterns of type ‘Char’ not matched: _ diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr index af9411c6a3..691c62b79d 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase002.stderr @@ -1,25 +1,25 @@ EmptyCase002.hs:16:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘T’ not matched: MkT _ + In a case alternative: Patterns of type ‘T’ not matched: MkT _ EmptyCase002.hs:43:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T1 B’ not matched: + Patterns of type ‘T1 B’ not matched: MkT1 B1 MkT1 B2 EmptyCase002.hs:47:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T1 (E Int)’ not matched: + Patterns of type ‘T1 (E Int)’ not matched: MkT1 False MkT1 True EmptyCase002.hs:51:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T1 - (T2 (T1 (D (E Int) (E (E Int)))))’ not matched: + Patterns of type ‘T1 + (T2 (T1 (D (E Int) (E (E Int)))))’ not matched: MkT1 (MkT2 (MkT1 D2)) diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr index c80a391d98..7dc717c934 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase004.stderr @@ -1,37 +1,37 @@ EmptyCase004.hs:15:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘A Bool’ not matched: A2 + In a case alternative: Patterns of type ‘A Bool’ not matched: A2 EmptyCase004.hs:19:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘A a’ not matched: + Patterns of type ‘A a’ not matched: A1 A2 EmptyCase004.hs:31:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘B a a’ not matched: B1 _ + In a case alternative: Patterns of type ‘B a a’ not matched: B1 _ EmptyCase004.hs:35:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘B a b’ not matched: + Patterns of type ‘B a b’ not matched: B1 _ B2 EmptyCase004.hs:47:6: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘A a’ not matched: + Patterns of type ‘A a’ not matched: A1 A2 EmptyCase004.hs:50:9: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘B a b’ not matched: B2 + In a case alternative: Patterns of type ‘B a b’ not matched: B2 EmptyCase004.hs:51:9: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘B a b’ not matched: B1 _ + In a case alternative: Patterns of type ‘B a b’ not matched: B1 _ diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr index 97514f67be..da479135f6 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase005.stderr @@ -2,34 +2,34 @@ EmptyCase005.hs:24:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Void3’ not matched: Void3 _ + Patterns of type ‘Void3’ not matched: Void3 _ EmptyCase005.hs:67:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T ()’ not matched: + Patterns of type ‘T ()’ not matched: T1 T2 EmptyCase005.hs:73:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T Bool’ not matched: + Patterns of type ‘T Bool’ not matched: MkTBool False MkTBool True EmptyCase005.hs:79:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘T Int’ not matched: MkTInt _ + Patterns of type ‘T Int’ not matched: MkTInt _ EmptyCase005.hs:91:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘G Int’ not matched: + Patterns of type ‘G Int’ not matched: MkV False MkV True EmptyCase005.hs:101:8: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘H Int’ not matched: _ + In a case alternative: Patterns of type ‘H Int’ not matched: _ diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr index a34d0f5e5e..9062f1c40a 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase006.stderr @@ -2,12 +2,12 @@ EmptyCase006.hs:18:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo1 Int’ not matched: Foo1 MkGA1 + Patterns of type ‘Foo1 Int’ not matched: Foo1 MkGA1 EmptyCase006.hs:26:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo1 a’ not matched: + Patterns of type ‘Foo1 a’ not matched: Foo1 MkGA1 Foo1 (MkGA2 _) Foo1 MkGA3 diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr index 6b60fd76ad..7adef0854a 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase007.stderr @@ -2,30 +2,30 @@ EmptyCase007.hs:21:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo2 a’ not matched: Foo2 _ + Patterns of type ‘Foo2 a’ not matched: Foo2 _ EmptyCase007.hs:25:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo2 (a, a)’ not matched: Foo2 _ + Patterns of type ‘Foo2 (a, a)’ not matched: Foo2 _ EmptyCase007.hs:33:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo2 Int’ not matched: Foo2 (_, _) + Patterns of type ‘Foo2 Int’ not matched: Foo2 (_, _) EmptyCase007.hs:37:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo2 Char’ not matched: Foo2 _ + Patterns of type ‘Foo2 Char’ not matched: Foo2 _ EmptyCase007.hs:44:17: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘FA Char’ not matched: _ + In a case alternative: Patterns of type ‘FA Char’ not matched: _ EmptyCase007.hs:48:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo2 [Int]’ not matched: + Patterns of type ‘Foo2 [Int]’ not matched: Foo2 [] Foo2 (_:_) diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr index 5563a599b6..c826a05569 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase008.stderr @@ -2,21 +2,21 @@ EmptyCase008.hs:17:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo3 Int’ not matched: + Patterns of type ‘Foo3 Int’ not matched: Foo3 (MkDA1 _) Foo3 MkDA2 EmptyCase008.hs:21:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo3 a’ not matched: Foo3 _ + Patterns of type ‘Foo3 a’ not matched: Foo3 _ EmptyCase008.hs:40:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo4 Int ()’ not matched: Foo4 MkDB1 + Patterns of type ‘Foo4 Int ()’ not matched: Foo4 MkDB1 EmptyCase008.hs:48:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Foo4 a b’ not matched: Foo4 _ + Patterns of type ‘Foo4 a b’ not matched: Foo4 _ diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr index cd10631c6c..ca6ca03e9f 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase009.stderr @@ -1,14 +1,14 @@ EmptyCase009.hs:21:9: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘Bar f’ not matched: Bar _ + In a case alternative: Patterns of type ‘Bar f’ not matched: Bar _ EmptyCase009.hs:33:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Bar (DB ())’ not matched: Bar MkDB2_u + Patterns of type ‘Bar (DB ())’ not matched: Bar MkDB2_u EmptyCase009.hs:42:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Bar GB’ not matched: Bar MkGB3 + Patterns of type ‘Bar GB’ not matched: Bar MkGB3 diff --git a/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr b/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr index 9b4c65e4ac..8202c65a22 100644 --- a/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr +++ b/testsuite/tests/pmcheck/should_compile/EmptyCase010.stderr @@ -2,31 +2,31 @@ EmptyCase010.hs:24:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz GC a’ not matched: + Patterns of type ‘Baz GC a’ not matched: Baz MkGC1 Baz (MkGC2 _) EmptyCase010.hs:28:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz GC 'T1’ not matched: Baz MkGC1 + Patterns of type ‘Baz GC 'T1’ not matched: Baz MkGC1 EmptyCase010.hs:37:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz GD Maybe’ not matched: + Patterns of type ‘Baz GD Maybe’ not matched: Baz MkGD1 Baz MkGD3 EmptyCase010.hs:41:9: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz GD (Either Int)’ not matched: Baz MkGD3 + Patterns of type ‘Baz GD (Either Int)’ not matched: Baz MkGD3 EmptyCase010.hs:45:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz GD f’ not matched: + Patterns of type ‘Baz GD f’ not matched: Baz MkGD1 Baz MkGD2 Baz MkGD3 @@ -34,14 +34,14 @@ EmptyCase010.hs:45:7: warning: [-Wincomplete-patterns (in -Wextra)] EmptyCase010.hs:57:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz (DC ()) a’ not matched: Baz _ + Patterns of type ‘Baz (DC ()) a’ not matched: Baz _ EmptyCase010.hs:69:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz (DC Bool) [Int]’ not matched: Baz MkDC2 + Patterns of type ‘Baz (DC Bool) [Int]’ not matched: Baz MkDC2 EmptyCase010.hs:73:9: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Baz f a’ not matched: Baz _ + Patterns of type ‘Baz f a’ not matched: Baz _ diff --git a/testsuite/tests/pmcheck/should_compile/T10746.stderr b/testsuite/tests/pmcheck/should_compile/T10746.stderr index fab96e5fde..a2229d3ec6 100644 --- a/testsuite/tests/pmcheck/should_compile/T10746.stderr +++ b/testsuite/tests/pmcheck/should_compile/T10746.stderr @@ -2,6 +2,6 @@ T10746.hs:9:10: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Bool’ not matched: + Patterns of type ‘Bool’ not matched: False True diff --git a/testsuite/tests/pmcheck/should_compile/T11336b.stderr b/testsuite/tests/pmcheck/should_compile/T11336b.stderr index 4a6547d509..85dad6a81c 100644 --- a/testsuite/tests/pmcheck/should_compile/T11336b.stderr +++ b/testsuite/tests/pmcheck/should_compile/T11336b.stderr @@ -1,5 +1,4 @@ T11336b.hs:25:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In an equation for ‘fun’: - Patterns of type ‘Proxy a’ not matched: Proxy + In an equation for ‘fun’: Patterns of type ‘Proxy a’ not matched: _ diff --git a/testsuite/tests/pmcheck/should_compile/T11822.stderr b/testsuite/tests/pmcheck/should_compile/T11822.stderr index 212d300537..7f0aae9aec 100644 --- a/testsuite/tests/pmcheck/should_compile/T11822.stderr +++ b/testsuite/tests/pmcheck/should_compile/T11822.stderr @@ -2,16 +2,15 @@ T11822.hs:33:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘mkTreeNode’: - Patterns of type ‘prefix’, ‘Seq SiblingDependencies’, - ‘Set prefix’, ‘Depth’ not matched: - _ (Data.Sequence.Internal.Seq Data.Sequence.Internal.EmptyT) - (Data.Set.Internal.Bin _ _ _ _) (Depth _) - _ (Data.Sequence.Internal.Seq Data.Sequence.Internal.EmptyT) - Data.Set.Internal.Tip (Depth _) - _ (Data.Sequence.Internal.Seq (Data.Sequence.Internal.Single _)) - (Data.Set.Internal.Bin _ _ _ _) (Depth _) - _ (Data.Sequence.Internal.Seq (Data.Sequence.Internal.Single _)) - Data.Set.Internal.Tip (Depth _) + Patterns of type ‘prefix’, ‘Seq SiblingDependencies’, ‘Set prefix’, + ‘Depth’ not matched: + _ (Data.Sequence.Internal.Seq Data.Sequence.Internal.EmptyT) _ _ + _ (Data.Sequence.Internal.Seq (Data.Sequence.Internal.Single _)) _ + _ + _ + (Data.Sequence.Internal.Seq (Data.Sequence.Internal.Deep _ _ _ _)) + _ _ + _ (Data.Sequence.Internal.Seq Data.Sequence.Internal.EmptyT) _ _ ... T11822.hs:33:1: warning: @@ -21,4 +20,3 @@ T11822.hs:33:1: warning: • Patterns reported as unmatched might actually be matched Suggested fix: Increase the limit or resolve the warnings to suppress this message. - diff --git a/testsuite/tests/pmcheck/should_compile/T15305.stderr b/testsuite/tests/pmcheck/should_compile/T15305.stderr index de682464b7..61f47322a0 100644 --- a/testsuite/tests/pmcheck/should_compile/T15305.stderr +++ b/testsuite/tests/pmcheck/should_compile/T15305.stderr @@ -2,4 +2,4 @@ T15305.hs:48:23: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Abyss’ not matched: MkAbyss _ + Patterns of type ‘Abyss’ not matched: MkAbyss _ diff --git a/testsuite/tests/pmcheck/should_compile/T15450.stderr b/testsuite/tests/pmcheck/should_compile/T15450.stderr index 2ef488970d..a9268100f1 100644 --- a/testsuite/tests/pmcheck/should_compile/T15450.stderr +++ b/testsuite/tests/pmcheck/should_compile/T15450.stderr @@ -2,10 +2,10 @@ T15450.hs:6:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘Bool’ not matched: + Patterns of type ‘Bool’ not matched: False True T15450.hs:9:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In a case alternative: Patterns of type ‘Bool’ not matched: False + In a case alternative: Patterns of type ‘Bool’ not matched: False diff --git a/testsuite/tests/pmcheck/should_compile/T17977.stderr b/testsuite/tests/pmcheck/should_compile/T17977.stderr index f9cb656f42..9817638af6 100644 --- a/testsuite/tests/pmcheck/should_compile/T17977.stderr +++ b/testsuite/tests/pmcheck/should_compile/T17977.stderr @@ -2,10 +2,7 @@ T17977.hs:31:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: - Patterns of type ‘SNat m’, ‘SNat n’, ‘SNat o’, - ‘R m n o’ not matched: - SZ SZ SZ _ - SZ SZ (SS _) _ - SZ (SS _) SZ _ - SZ (SS _) (SS _) _ - ... + Patterns of type ‘SNat m’, ‘SNat n’, ‘SNat o’, + ‘R m n o’ not matched: + SZ _ _ _ + (SS _) _ SZ _ diff --git a/testsuite/tests/pmcheck/should_compile/T18610.stderr b/testsuite/tests/pmcheck/should_compile/T18610.stderr index 7f6a2dfe67..cc2ddf2996 100644 --- a/testsuite/tests/pmcheck/should_compile/T18610.stderr +++ b/testsuite/tests/pmcheck/should_compile/T18610.stderr @@ -6,7 +6,7 @@ T18610.hs:15:3: warning: [-Woverlapping-patterns (in -Wdefault)] T18610.hs:24:7: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘(Bool, Bool)’ not matched: (_, _) + Patterns of type ‘(Bool, Bool)’ not matched: _ T18610.hs:53:3: warning: [-Winaccessible-code (in -Wdefault)] • Couldn't match type ‘Bool’ with ‘Int’ diff --git a/testsuite/tests/pmcheck/should_compile/T18932.stderr b/testsuite/tests/pmcheck/should_compile/T18932.stderr index 7f6d813ada..1da153f795 100644 --- a/testsuite/tests/pmcheck/should_compile/T18932.stderr +++ b/testsuite/tests/pmcheck/should_compile/T18932.stderr @@ -5,15 +5,12 @@ T18932.hs:10:1: warning: [-Woverlapping-patterns (in -Wdefault)] T18932.hs:12:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In an equation for ‘f'’: - Patterns of type ‘T a’ not matched: MkT2 _ + In an equation for ‘f'’: Patterns of type ‘T a’ not matched: MkT2 _ T18932.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘g’: - Patterns of type ‘T a’, ‘T a’, ‘T a’ not matched: - (MkT2 _) (MkT1 _) (MkT1 _) - (MkT2 _) (MkT1 _) (MkT2 _) - (MkT2 _) (MkT2 _) (MkT1 _) - (MkT2 _) (MkT2 _) (MkT2 _) - ... + Patterns of type ‘T a’, ‘T a’, ‘T a’ not matched: + (MkT2 _) _ _ + (MkT1 _) (MkT2 _) _ + (MkT1 _) (MkT1 _) (MkT2 _) diff --git a/testsuite/tests/pmcheck/should_compile/T20642.hs b/testsuite/tests/pmcheck/should_compile/T20642.hs new file mode 100644 index 0000000000..f7b1867b67 --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T20642.hs @@ -0,0 +1,18 @@ +{-# LANGUAGE EmptyCase #-} +{-# OPTIONS_GHC -Wincomplete-uni-patterns #-} + +module T20642 where + +foo :: [a] -> [a] +foo [] = [] +foo xs = ys + where + (_, ys@(_:_)) = splitAt 0 xs + +-- Should case split on the Maybe +f :: Maybe a -> () +f x = case x of {} + +-- Should *not* case split on the Bool +g :: (Bool, [a]) -> () +g (_, []) = () diff --git a/testsuite/tests/pmcheck/should_compile/T20642.stderr b/testsuite/tests/pmcheck/should_compile/T20642.stderr new file mode 100644 index 0000000000..3843b53045 --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T20642.stderr @@ -0,0 +1,17 @@ + +T20642.hs:10:3: warning: [-Wincomplete-uni-patterns (in -Wall)] + Pattern match(es) are non-exhaustive + In a pattern binding: + Patterns of type ‘([a], [a])’ not matched: (_, []) + +T20642.hs:14:7: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In a case alternative: + Patterns of type ‘Maybe a’ not matched: + Nothing + Just _ + +T20642.hs:18:1: warning: [-Wincomplete-patterns (in -Wextra)] + Pattern match(es) are non-exhaustive + In an equation for ‘g’: + Patterns of type ‘(Bool, [a])’ not matched: (_, (_:_)) diff --git a/testsuite/tests/pmcheck/should_compile/T2204.stderr b/testsuite/tests/pmcheck/should_compile/T2204.stderr index 82988e669c..5bd3dba322 100644 --- a/testsuite/tests/pmcheck/should_compile/T2204.stderr +++ b/testsuite/tests/pmcheck/should_compile/T2204.stderr @@ -2,14 +2,14 @@ T2204.hs:6:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: - Patterns of type ‘String’ not matched: + Patterns of type ‘String’ not matched: [] - [p] where p is not one of {'0'} - (p:_:_) where p is not one of {'0'} + (p:_) where p is not one of {'0'} ['0'] + ('0':p:_) where p is not one of {'1'} ... T2204.hs:9:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘g’: - Patterns of type ‘Int’ not matched: p where p is not one of {0} + Patterns of type ‘Int’ not matched: p where p is not one of {0} diff --git a/testsuite/tests/pmcheck/should_compile/T9951b.stderr b/testsuite/tests/pmcheck/should_compile/T9951b.stderr index 65198db65f..c446661366 100644 --- a/testsuite/tests/pmcheck/should_compile/T9951b.stderr +++ b/testsuite/tests/pmcheck/should_compile/T9951b.stderr @@ -2,9 +2,9 @@ T9951b.hs:7:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: - Patterns of type ‘String’ not matched: + Patterns of type ‘String’ not matched: [] - [p] where p is not one of {'a'} - (p:_:_) where p is not one of {'a'} + (p:_) where p is not one of {'a'} ['a'] + ('a':p:_) where p is not one of {'b'} ... diff --git a/testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr b/testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr index 9297e1b669..bd9ca3f0f0 100644 --- a/testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr +++ b/testsuite/tests/pmcheck/should_compile/TooManyDeltas.stderr @@ -1,12 +1,7 @@ TooManyDeltas.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive - In an equation for ‘f’: - Patterns of type ‘T’, ‘T’ not matched: - A A - A B - B A - B B + In an equation for ‘f’: Patterns of type ‘T’, ‘T’ not matched: _ _ TooManyDeltas.hs:14:1: warning: Pattern match checker ran into -fmax-pmcheck-models=0 limit, so diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index f1cc928151..8df4d33d8a 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -170,6 +170,8 @@ test('T19622', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T20631', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T20642', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, diff --git a/testsuite/tests/pmcheck/should_compile/pmc001.stderr b/testsuite/tests/pmcheck/should_compile/pmc001.stderr index 6f15444777..4e10c5bf0a 100644 --- a/testsuite/tests/pmcheck/should_compile/pmc001.stderr +++ b/testsuite/tests/pmcheck/should_compile/pmc001.stderr @@ -2,7 +2,7 @@ pmc001.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: - Patterns of type ‘T [a]’, ‘T [a]’ not matched: + Patterns of type ‘T [a]’, ‘T [a]’ not matched: MkT1 MkT3 (MkT2 _) MkT3 MkT3 MkT1 @@ -11,7 +11,7 @@ pmc001.hs:14:1: warning: [-Wincomplete-patterns (in -Wextra)] pmc001.hs:19:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘g’: - Patterns of type ‘T [a]’, ‘T [a]’ not matched: + Patterns of type ‘T [a]’, ‘T [a]’ not matched: MkT1 MkT3 (MkT2 _) MkT3 MkT3 MkT1 diff --git a/testsuite/tests/pmcheck/should_compile/pmc007.stderr b/testsuite/tests/pmcheck/should_compile/pmc007.stderr index 1593f85f7f..a68618d3f2 100644 --- a/testsuite/tests/pmcheck/should_compile/pmc007.stderr +++ b/testsuite/tests/pmcheck/should_compile/pmc007.stderr @@ -2,25 +2,25 @@ pmc007.hs:7:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘f’: - Patterns of type ‘a’ not matched: + Patterns of type ‘a’ not matched: p where p is not one of {"ab", "ac"} pmc007.hs:12:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘g’: - Patterns of type ‘String’ not matched: + Patterns of type ‘String’ not matched: [] - [p] where p is not one of {'a'} - (p:_:_) where p is not one of {'a'} + (p:_) where p is not one of {'a'} ['a'] + ('a':p:_) where p is not one of {'b', 'c'} ... pmc007.hs:18:11: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In a case alternative: - Patterns of type ‘String’ not matched: + Patterns of type ‘String’ not matched: [] - [p] where p is not one of {'a'} - (p:_:_) where p is not one of {'a'} + (p:_) where p is not one of {'a'} ['a'] + ('a':p:_) where p is not one of {'b', 'c'} ... diff --git a/testsuite/tests/pmcheck/should_compile/pmc009.stderr b/testsuite/tests/pmcheck/should_compile/pmc009.stderr index 6f1849a25f..21132abc08 100644 --- a/testsuite/tests/pmcheck/should_compile/pmc009.stderr +++ b/testsuite/tests/pmcheck/should_compile/pmc009.stderr @@ -2,5 +2,4 @@ pmc009.hs:6:1: warning: [-Wincomplete-patterns (in -Wextra)] Pattern match(es) are non-exhaustive In an equation for ‘addPatSynSelector’: - Patterns of type ‘GenLocated l (HsBindLR idL idR)’ not matched: - L _ _ + Patterns of type ‘GenLocated l (HsBindLR idL idR)’ not matched: _ |