summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/simplCore/should_compile/T20820.hs29
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T5
2 files changed, 34 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T20820.hs b/testsuite/tests/simplCore/should_compile/T20820.hs
new file mode 100644
index 0000000000..546f61e919
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T20820.hs
@@ -0,0 +1,29 @@
+module T20820 ( ) where
+
+import Prelude hiding (concat)
+import Data.Semigroup (Semigroup (sconcat, stimes))
+import Data.List.NonEmpty (NonEmpty ((:|)))
+
+data ByteString = BS
+
+instance Semigroup ByteString where
+ (<>) = undefined
+ sconcat (b:|bs) = concat (b:bs)
+ stimes = stimesPolymorphic
+instance Monoid ByteString where
+ mempty = undefined
+
+concat :: [ByteString] -> ByteString
+concat = undefined
+{-# NOINLINE concat #-}
+
+{-# RULES
+"ByteString concat [] -> mempty"
+ concat [] = mempty
+ #-}
+
+stimesPolymorphic :: Integral a => a -> ByteString -> ByteString
+stimesPolymorphic nRaw bs = stimesInt (fromIntegral nRaw) bs
+
+stimesInt :: Int -> ByteString -> ByteString
+stimesInt _ BS = mempty
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index 4915d4b273..034a76fadd 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -374,3 +374,8 @@ test('T20200KG', [extra_files(['T20200KGa.hs', 'T20200KG.hs-boot'])], multimod_c
test('T20639', normal, compile, ['-O2'])
test('T20894', normal, compile, ['-dcore-lint -O1 -ddebug-output'])
test('T19790', normal, compile, ['-O -ddump-rule-firings'])
+
+# This one had a Lint failure due to an occurrence analysis bug
+# -O0 is needed to trigger it because that switches rules off,
+# which (before the fix) lost crucial dependencies
+test('T20820', normal, compile, ['-O0'])