filter/filter rules are incorrect
meooow25 opened this issue · comments
Soumik Sarkar commented
import qualified Data.Text as T
main = print $ T.filter (const undefined) $ T.filter (const False) $ T.singleton 'a'
Without optimizations, prints
""
With optimizations,
tfilter: Prelude.undefined
CallStack (from HasCallStack):
undefined, called at tfilter.hs:2:32 in main:Main
Lines 1660 to 1663 in 456783a
Lines 1691 to 1694 in 456783a
The problem is that the predicate of the inner filter is not checked first.
The rule in the stream code is, however, correct
text/src/Data/Text/Internal/Fusion/Common.hs
Lines 1113 to 1116 in 456783a
Soumik Sarkar commented
For the record, I happened to notice this in the code. I did not find this out the hard way.