summaryrefslogtreecommitdiff
path: root/testsuite/tests/stranal
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-10-02 15:25:02 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2017-10-03 09:52:39 +0100
commitdbbee1bacef1a8accc630908c31cf267a3cb98a9 (patch)
tree8ad36f1ed3b80f4bdd9a081aa6cb2fd201eb8a8e /testsuite/tests/stranal
parentb1e0c65a1302f998917e6d33d6e1ebb84cd09fa8 (diff)
downloadhaskell-dbbee1bacef1a8accc630908c31cf267a3cb98a9.tar.gz
Fix nasty bug in w/w for absence analysis
This dark corner was exposed by Trac #14285. It involves the interaction between absence analysis and INLINABLE pragmas. There is a full explanation in Note [aBSENT_ERROR_ID] in MkCore, which you can read there. The changes in this patch are * Make exprIsHNF return True for absentError, treating absentError like an honorary data constructor. * Make absentError /not/ be diverging, unlike other error Ids. This is all a bit horrible. * While doing this I found that exprOkForSpeculation didn't have a case for value lambdas so I added one. It's not really called on lifted types much, but it seems like the right thing
Diffstat (limited to 'testsuite/tests/stranal')
-rw-r--r--testsuite/tests/stranal/should_run/T14285.hs9
-rw-r--r--testsuite/tests/stranal/should_run/T14285.stdout1
-rw-r--r--testsuite/tests/stranal/should_run/T14285a.hs37
-rw-r--r--testsuite/tests/stranal/should_run/all.T1
4 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/tests/stranal/should_run/T14285.hs b/testsuite/tests/stranal/should_run/T14285.hs
new file mode 100644
index 0000000000..29da51e734
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T14285.hs
@@ -0,0 +1,9 @@
+module Main where
+
+import T14285a
+import Prelude hiding (null)
+
+main :: IO ()
+main = do
+ let args = "hw"
+ print $ null $ pre_images 'a' (Rel (fromList [('a',sfromList args)]) (fromList [('b',sfromList args)]))
diff --git a/testsuite/tests/stranal/should_run/T14285.stdout b/testsuite/tests/stranal/should_run/T14285.stdout
new file mode 100644
index 0000000000..0ca95142bb
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T14285.stdout
@@ -0,0 +1 @@
+True
diff --git a/testsuite/tests/stranal/should_run/T14285a.hs b/testsuite/tests/stranal/should_run/T14285a.hs
new file mode 100644
index 0000000000..8ee9b38df6
--- /dev/null
+++ b/testsuite/tests/stranal/should_run/T14285a.hs
@@ -0,0 +1,37 @@
+module T14285a where
+
+import qualified Data.Foldable as F
+import qualified Data.IntMap as IM
+import qualified Data.IntSet as IS
+import Prelude hiding (null)
+
+data Set k = Set IS.IntSet
+
+empty = Set IS.empty
+
+
+null (Set a) = IS.null a
+
+sfromList :: (Enum a, Foldable c) => c a -> Set a
+sfromList xs = Set $ IS.fromList $ Prelude.map fromEnum $ F.toList xs
+
+{-# inlineable fromList #-}
+fromList :: Enum k => [(k,v)] -> Map k v
+fromList kvs =
+ Map $ IM.fromList $ Prelude.map (\(k,v) -> (fromEnum k, v)) kvs
+
+
+newtype Map k v = Map { unMap :: (IM.IntMap v) } deriving (Eq, Ord)
+
+{-# inlineable findWithDefault #-}
+findWithDefault d k (Map m) = IM.findWithDefault d (fromEnum k) m
+
+data Rel a b = Rel !(Map a (Set b)) !(Map b (Set a))
+
+{-# INLINEABLE images #-}
+images x (Rel f b) = findWithDefault empty x f
+{-# INLINEABLE pre_images #-}
+pre_images x rel = images x $ mirrorRel rel
+{-# INLINEABLE mirrorRel #-}
+mirrorRel :: Rel a b -> Rel b a
+mirrorRel (Rel f g) = Rel g f
diff --git a/testsuite/tests/stranal/should_run/all.T b/testsuite/tests/stranal/should_run/all.T
index dada8176cb..a9cc3d7071 100644
--- a/testsuite/tests/stranal/should_run/all.T
+++ b/testsuite/tests/stranal/should_run/all.T
@@ -16,3 +16,4 @@ test('T12368', exit_code(1), compile_and_run, [''])
test('T12368a', exit_code(1), compile_and_run, [''])
test('T13380', [expect_broken(13380), exit_code(1)], compile_and_run, [''])
test('T14290', normal, compile_and_run, [''])
+test('T14285', normal, multimod_compile_and_run, ['T14285', ''])