summaryrefslogtreecommitdiff
path: root/testsuite/tests
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2021-03-05 12:48:57 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-14 12:55:45 -0400
commit1793ca9d43bd5e78eb9e7d6e4212bf6196812786 (patch)
tree1efe9b16ffcdb9f725585c6086c0aeb86e5f2eae /testsuite/tests
parentcd793767a1f388d10cda69f244479b63536f0a3d (diff)
downloadhaskell-1793ca9d43bd5e78eb9e7d6e4212bf6196812786.tar.gz
Pmc: Consider Required Constraints when guessing PatSyn arg types (#19475)
This patch makes `guessConLikeUnivTyArgsFromResTy` consider required Thetas of PatSynCons, by treating them as Wanted constraints to be discharged with the constraints from the Nabla's TyState and saying "does not match the match type" if the Wanted constraints are unsoluble. It calls out into a new function `GHC.Tc.Solver.tcCheckWanteds` to do so. In pushing the failure logic around call sites of `initTcDsForSolver` inside it by panicking, I realised that there was a bunch of dead code surrounding `pmTopMoraliseType`: I was successfully able to delete the `NoChange` data constructor of `TopNormaliseTypeResult`. The details are in `Note [Matching against a ConLike result type]` and `Note [Instantiating a ConLike]. The regression test is in `T19475`. It's pretty much a fork of `T14422` at the moment. Co-authored-by: Cale Gibbard <cgibbard@gmail.com>
Diffstat (limited to 'testsuite/tests')
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T14422.stderr4
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T19475.hs19
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T19475.stderr4
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/all.T1
4 files changed, 26 insertions, 2 deletions
diff --git a/testsuite/tests/pmcheck/complete_sigs/T14422.stderr b/testsuite/tests/pmcheck/complete_sigs/T14422.stderr
index 26a03573ae..564233a189 100644
--- a/testsuite/tests/pmcheck/complete_sigs/T14422.stderr
+++ b/testsuite/tests/pmcheck/complete_sigs/T14422.stderr
@@ -1,8 +1,8 @@
T14422.hs:31:1: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In an equation for ‘g’: Patterns of type ‘f a’ not matched: P
+ In an equation for ‘g’: Patterns of type ‘f a’ not matched: _
T14422.hs:44:1: warning: [-Wincomplete-patterns (in -Wextra)]
Pattern match(es) are non-exhaustive
- In an equation for ‘i’: Patterns of type ‘f a’ not matched: P
+ In an equation for ‘i’: Patterns of type ‘f a’ not matched: _
diff --git a/testsuite/tests/pmcheck/complete_sigs/T19475.hs b/testsuite/tests/pmcheck/complete_sigs/T19475.hs
new file mode 100644
index 0000000000..beb63e6745
--- /dev/null
+++ b/testsuite/tests/pmcheck/complete_sigs/T19475.hs
@@ -0,0 +1,19 @@
+{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE ViewPatterns #-}
+
+module T19475 where
+
+class C f where
+ foo :: f a -> ()
+pattern P :: C f => f a
+pattern P <- (foo -> ())
+{-# COMPLETE P #-}
+
+class D f where
+ bar :: f a -> ()
+pattern Q :: D f => f a
+pattern Q <- (bar -> ())
+
+g :: D f => f a -> ()
+g Q = () -- Warning should not suggest P!
diff --git a/testsuite/tests/pmcheck/complete_sigs/T19475.stderr b/testsuite/tests/pmcheck/complete_sigs/T19475.stderr
new file mode 100644
index 0000000000..035f80475a
--- /dev/null
+++ b/testsuite/tests/pmcheck/complete_sigs/T19475.stderr
@@ -0,0 +1,4 @@
+
+T19475.hs:19:1: warning: [-Wincomplete-patterns (in -Wextra)]
+ Pattern match(es) are non-exhaustive
+ In an equation for ‘g’: Patterns of type ‘f a’ not matched: _
diff --git a/testsuite/tests/pmcheck/complete_sigs/all.T b/testsuite/tests/pmcheck/complete_sigs/all.T
index 49ed3c62bc..06bbf017b3 100644
--- a/testsuite/tests/pmcheck/complete_sigs/all.T
+++ b/testsuite/tests/pmcheck/complete_sigs/all.T
@@ -28,3 +28,4 @@ test('T17386', normal, compile, [''])
test('T18277', normal, compile, [''])
test('T18960', normal, compile, [''])
test('T18960b', normal, compile, [''])
+test('T19475', normal, compile, [''])