summaryrefslogtreecommitdiff
path: root/testsuite/tests/pmcheck
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2020-09-01 19:00:37 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-09-12 00:32:13 -0400
commit2a9422859e0c079aaa38bb9a760034f887501fce (patch)
tree571a816809930cf86fb302cd524fc050e9f045cc /testsuite/tests/pmcheck
parentfb6e29e8d19deaf7581fdef14adc88a02573c83e (diff)
downloadhaskell-2a9422859e0c079aaa38bb9a760034f887501fce.tar.gz
PmCheck: Disattach COMPLETE pragma lookup from TyCons
By not attaching COMPLETE pragmas with a particular TyCon and instead assume that every COMPLETE pragma is applicable everywhere, we can drastically simplify the logic that tries to initialise available COMPLETE sets of a variable during the pattern-match checking process, as well as fixing a few bugs. Of course, we have to make sure not to report any of the ill-typed/unrelated COMPLETE sets, which came up in a few regression tests. In doing so, we fix #17207, #18277 and #14422. There was a metric decrease in #18478 by ~20%. Metric Decrease: T18478
Diffstat (limited to 'testsuite/tests/pmcheck')
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T14422.hs (renamed from testsuite/tests/pmcheck/complete_sigs/completesig15.hs)3
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T18277.hs13
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/all.T5
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/completesig04.hs12
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/completesig04.stderr13
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/completesig15.stderr4
-rw-r--r--testsuite/tests/pmcheck/should_compile/all.T2
7 files changed, 39 insertions, 13 deletions
diff --git a/testsuite/tests/pmcheck/complete_sigs/completesig15.hs b/testsuite/tests/pmcheck/complete_sigs/T14422.hs
index 5936379aa7..be879f4b13 100644
--- a/testsuite/tests/pmcheck/complete_sigs/completesig15.hs
+++ b/testsuite/tests/pmcheck/complete_sigs/T14422.hs
@@ -10,3 +10,6 @@ pattern P :: C f => f a
pattern P <- (foo -> ())
{-# COMPLETE P #-}
+
+f :: C f => f a -> ()
+f P = () -- A complete match
diff --git a/testsuite/tests/pmcheck/complete_sigs/T18277.hs b/testsuite/tests/pmcheck/complete_sigs/T18277.hs
new file mode 100644
index 0000000000..db09edf65a
--- /dev/null
+++ b/testsuite/tests/pmcheck/complete_sigs/T18277.hs
@@ -0,0 +1,13 @@
+{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
+{-# LANGUAGE PatternSynonyms #-}
+
+module Lib where
+
+type List = []
+
+pattern DefinitelyAString :: String -> String
+pattern DefinitelyAString x = x
+{-# COMPLETE DefinitelyAString #-}
+
+f :: String -> String
+f (DefinitelyAString x) = x
diff --git a/testsuite/tests/pmcheck/complete_sigs/all.T b/testsuite/tests/pmcheck/complete_sigs/all.T
index bc4f39ac39..2728121160 100644
--- a/testsuite/tests/pmcheck/complete_sigs/all.T
+++ b/testsuite/tests/pmcheck/complete_sigs/all.T
@@ -1,7 +1,7 @@
test('completesig01', normal, compile, [''])
test('completesig02', normal, compile, [''])
test('Completesig03', normal, multimod_compile, ['Completesig03', '-Wall'])
-test('completesig04', normal, compile_fail, [''])
+test('completesig04', normal, compile, ['-Wincomplete-patterns'])
test('completesig05', normal, compile, [''])
test('completesig06', normal, compile, [''])
test('completesig07', normal, compile, [''])
@@ -12,7 +12,6 @@ test('completesig11', normal, compile, [''])
test('completesig12', normal, compile, [''])
test('completesig13', normal, compile, [''])
test('completesig14', normal, compile, [''])
-test('completesig15', normal, compile_fail, [''])
test('T13021', normal, compile, [''])
test('T13363a', normal, compile, [''])
test('T13363b', normal, compile, [''])
@@ -22,6 +21,8 @@ test('T13965', normal, compile, [''])
test('T14059a', normal, compile, [''])
test('T14059b', expect_broken('14059'), compile, [''])
test('T14253', normal, compile, [''])
+test('T14422', normal, compile, [''])
test('T14851', normal, compile, [''])
test('T17149', normal, compile, [''])
test('T17386', normal, compile, [''])
+test('T18277', normal, compile, [''])
diff --git a/testsuite/tests/pmcheck/complete_sigs/completesig04.hs b/testsuite/tests/pmcheck/complete_sigs/completesig04.hs
index dbe1110be1..d8f84cb71d 100644
--- a/testsuite/tests/pmcheck/complete_sigs/completesig04.hs
+++ b/testsuite/tests/pmcheck/complete_sigs/completesig04.hs
@@ -1,6 +1,12 @@
--- Test that a COMPLETE pragma over constructors of different types fails.
+{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
+-- Test that a COMPLETE pragma over constructors of different types is a valid
+-- declaration, but that it's not suggested in any warning.
module TyMismatch where
-data E = L | R
+data T = A | B | C
-{-# COMPLETE Just, L #-}
+{-# COMPLETE Just, A #-}
+
+f A = () -- should not suggest 'Just'
+
+g (Just _) = () -- should not suggest 'A'
diff --git a/testsuite/tests/pmcheck/complete_sigs/completesig04.stderr b/testsuite/tests/pmcheck/complete_sigs/completesig04.stderr
index 21a6377ba3..a114d0199e 100644
--- a/testsuite/tests/pmcheck/complete_sigs/completesig04.stderr
+++ b/testsuite/tests/pmcheck/complete_sigs/completesig04.stderr
@@ -1,4 +1,11 @@
-completesig04.hs:6:1: error:
- • Cannot form a group of complete patterns from patterns ‘Just’ and ‘L’ as they match different type constructors (‘Maybe’ resp. ‘E’)
- • In {-# COMPLETE Just, L #-}
+completesig04.hs:10:1: warning: [-Wincomplete-patterns (in -Wextra)]
+ Pattern match(es) are non-exhaustive
+ In an equation for ‘f’:
+ Patterns not matched:
+ B
+ C
+
+completesig04.hs:12:1: warning: [-Wincomplete-patterns (in -Wextra)]
+ Pattern match(es) are non-exhaustive
+ In an equation for ‘g’: Patterns not matched: Nothing
diff --git a/testsuite/tests/pmcheck/complete_sigs/completesig15.stderr b/testsuite/tests/pmcheck/complete_sigs/completesig15.stderr
deleted file mode 100644
index 3bff495ebe..0000000000
--- a/testsuite/tests/pmcheck/complete_sigs/completesig15.stderr
+++ /dev/null
@@ -1,4 +0,0 @@
-
-completesig15.hs:12:1: error:
- • A type signature must be provided for a set of polymorphic pattern synonyms.
- • In {-# COMPLETE P #-}
diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T
index de0998ba29..e8938be163 100644
--- a/testsuite/tests/pmcheck/should_compile/all.T
+++ b/testsuite/tests/pmcheck/should_compile/all.T
@@ -88,7 +88,7 @@ test('T17112', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T17207', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
-test('T17207b', expect_broken(17207), compile,
+test('T17207b', normal, compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])
test('T17208', expect_broken(17208), compile,
['-fwarn-incomplete-patterns -fwarn-overlapping-patterns'])