diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2020-08-10 17:58:17 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-08-13 03:44:52 -0400 |
commit | 55dec4dc6e8f8430810d212c73e78ffbb92e0a48 (patch) | |
tree | 2880ec2360764311c30afdba74ace624ef642cb1 /testsuite | |
parent | 7831fe05021caa90d4696ca91ae2b31a82e65b3d (diff) | |
download | haskell-55dec4dc6e8f8430810d212c73e78ffbb92e0a48.tar.gz |
PmCheck: Better long-distance info for where bindings (#18533)
Where bindings can see evidence from the pattern match of the `GRHSs`
they belong to, but not from anything in any of the guards (which belong
to one of possibly many RHSs).
Before this patch, we did *not* consider said evidence, causing #18533,
where the lack of considering type information from a case pattern match
leads to failure to resolve the vanilla COMPLETE set of a data type.
Making available that information required a medium amount of
refactoring so that `checkMatches` can return a
`[(Deltas, NonEmpty Deltas)]`; one `(Deltas, NonEmpty Deltas)` for each
`GRHSs` of the match group. The first component of the pair is the
covered set of the pattern, the second component is one covered set per
RHS.
Fixes #18533.
Regression test case: T18533
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T18533.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/all.T | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/testsuite/tests/pmcheck/should_compile/T18533.hs b/testsuite/tests/pmcheck/should_compile/T18533.hs new file mode 100644 index 0000000000..3b4fdf8b89 --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T18533.hs @@ -0,0 +1,24 @@ +{-# OPTIONS_GHC -Wincomplete-patterns -fforce-recomp #-} +{-# LANGUAGE GADTs, DataKinds, TypeFamilies, BangPatterns #-} + +module T18533 where + +data SBool (b :: Bool) where + STrue :: SBool 'True + SFalse :: SBool 'False + +type family Fam (b :: Bool) +type instance Fam 'True = T + +data T = T Bool + +f :: Fam b -> SBool b -> Bool +f !t s = case s of + STrue -> a where a = case t of T a -> a + _ -> False + + +g :: Bool -> Bool +g x = case x of + True -> a where a = case x of True -> False + False -> True diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index 57527977ff..054ad82873 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -122,6 +122,8 @@ test('T18049', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T18478', collect_compiler_stats('bytes allocated',10), compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T18533', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, |