summaryrefslogtreecommitdiff
path: root/testsuite/tests/pmcheck/complete_sigs/T18960.hs
diff options
context:
space:
mode:
authorSebastian Graf <sebastian.graf@kit.edu>2020-11-19 14:32:33 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-01-17 05:46:45 -0500
commit23a545df75002060ed7bcb8bcc0e0511b7f9fb7d (patch)
treecfd5a6eb4d7939517af036c0e27b21f756f50e92 /testsuite/tests/pmcheck/complete_sigs/T18960.hs
parentfe344da9be83be4c7c0c7f76183acfe0a234cc5d (diff)
downloadhaskell-23a545df75002060ed7bcb8bcc0e0511b7f9fb7d.tar.gz
PmCheck: Positive info doesn't imply there is an inhabitant (#18960)
Consider `T18960`: ```hs pattern P :: a -> a pattern P x = x {-# COMPLETE P :: () #-} foo :: () foo = case () of P _ -> () ``` We know about the match variable of the case match that it is equal to `()`. After the match on `P`, we still know it's equal to `()` (positive info), but also that it can't be `P` (negative info). By the `COMPLETE` pragma, we know that implies that the refinement type of the match variable is empty after the `P` case. But in the PmCheck solver, we assumed that "has positive info" means "is not empty", thus assuming we could omit a costly inhabitation test. Which is wrong, as we saw above. A bit of a complication arises because the "has positive info" spared us from doing a lot of inhabitation tests in `T17836b`. So we keep that check, but give it a lower priority than the check for dirty variables that requires us doing an inhabitation test. Needless to say: This doesn't impact soundness of the checker at all, it just implements a better trade-off between efficiency and precision. Fixes #18960. Metric Decrease: T17836
Diffstat (limited to 'testsuite/tests/pmcheck/complete_sigs/T18960.hs')
-rw-r--r--testsuite/tests/pmcheck/complete_sigs/T18960.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/complete_sigs/T18960.hs b/testsuite/tests/pmcheck/complete_sigs/T18960.hs
new file mode 100644
index 0000000000..ed441647d7
--- /dev/null
+++ b/testsuite/tests/pmcheck/complete_sigs/T18960.hs
@@ -0,0 +1,13 @@
+{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-}
+{-# LANGUAGE PatternSynonyms #-}
+
+module T18960 where
+
+pattern P :: a -> a
+pattern P x = x
+{-# COMPLETE P :: () #-}
+
+foo :: ()
+foo = case () of
+ P _ -> ()
+