diff options
author | Sebastian Graf <sebastian.graf@kit.edu> | 2021-11-07 13:09:06 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-11-07 16:26:46 -0500 |
commit | 56705da84a8e954d9755270ca8bb37a43d7d03a9 (patch) | |
tree | 6e56c958bacdbb467b038eb2dad5ae0a0895569d /testsuite | |
parent | 184f6bc6f17360421eb101c9deffb7f701072885 (diff) | |
download | haskell-56705da84a8e954d9755270ca8bb37a43d7d03a9.tar.gz |
Pmc: Do inhabitation test for unlifted vars (#20631)
Although I thought we were already set to handle unlifted datatypes correctly,
it appears we weren't. #20631 showed that it's wrong to assume
`vi_bot=IsNotBot` for `VarInfo`s of unlifted types from their inception if we
don't follow up with an inhabitation test to see if there are any habitable
constructors left. We can't trigger the test from `emptyVarInfo`, so now we
instead fail early in `addBotCt` for variables of unlifted types.
Fixed #20631.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/pmcheck/should_compile/T20631.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/T20631.hs b/testsuite/tests/pmcheck/should_compile/T20631.hs new file mode 100644 index 0000000000..d255c521ba --- /dev/null +++ b/testsuite/tests/pmcheck/should_compile/T20631.hs @@ -0,0 +1,24 @@ +{-# LANGUAGE UnliftedDatatypes #-} +{-# OPTIONS_GHC -fwarn-incomplete-patterns #-} +module Lib where +import Data.Kind (Type) +import GHC.Exts (UnliftedType) + +type Foo :: UnliftedType -> Type -> Type +data Foo a b = + Bar a -- no need for strictness annotation + | Baz b + +type MyVoid :: UnliftedType +data MyVoid + +v :: Foo MyVoid Char +v = Baz 'c' + +main :: IO () +main = case v of + -- The Baz case is impossible + -- MyVoid has no values, and it can't + -- be undefined because it's unlifted. + Baz c -> putChar c + diff --git a/testsuite/tests/pmcheck/should_compile/all.T b/testsuite/tests/pmcheck/should_compile/all.T index c732ef5691..f1cc928151 100644 --- a/testsuite/tests/pmcheck/should_compile/all.T +++ b/testsuite/tests/pmcheck/should_compile/all.T @@ -168,6 +168,8 @@ test('T18932', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) test('T19622', normal, compile, ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) +test('T20631', normal, compile, + ['-fwarn-incomplete-patterns -fwarn-overlapping-patterns']) # Other tests test('pmc001', [], compile, |