diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-11-19 14:32:33 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-01-17 05:46:45 -0500 |
commit | 23a545df75002060ed7bcb8bcc0e0511b7f9fb7d (patch) | |
tree | cfd5a6eb4d7939517af036c0e27b21f756f50e92 /testsuite/tests/pmcheck/complete_sigs/T18960.hs | |
parent | fe344da9be83be4c7c0c7f76183acfe0a234cc5d (diff) | |
download | haskell-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.hs | 13 |
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 _ -> () + |