diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2022-02-25 17:34:17 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-13 18:12:12 -0400 |
commit | ad83553153278947f439951d79a842527f2f0983 (patch) | |
tree | 875d56cb724ac77b75af9fc20fcdf156556221f3 /testsuite | |
parent | ed04aed2b2d87d605c1cd13161bd3511e43c9452 (diff) | |
download | haskell-ad83553153278947f439951d79a842527f2f0983.tar.gz |
Fix bug in weak loop-breakers in OccurAnal
Note [Weak loop breakers] explains why we need to track variables free
in RHS of rules. But we need to do this for /inactive/ rules as well
as active ones, unlike the rhs_fv_env stuff.
So we now have two fields in node Details, one for free vars of
active rules, and one for free vars of all rules.
This was shown up by #20820, which is now fixed.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/simplCore/should_compile/T20820.hs | 29 | ||||
-rw-r--r-- | testsuite/tests/simplCore/should_compile/all.T | 5 |
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']) |