Skip to content

Mysterious issue with bytestring "LazyWord8.fromString literal" test

Reproduction

git clone https://github.com/haskell/bytestring
cd bytestring
# git checkout 06cbef10f4869c6afdac210a22d9813b4f7f2fe6

Run tests with GHC 8.10 and 9.0, both should succeed:

$ cabal run -w ghc-8.10.4 prop-compiled -- --hide-successes -p "LazyWord8.fromString literal"
All 1 tests passed (0.00s)
$ cabal run -w ghc-9.0.1 prop-compiled -- --hide-successes -p "LazyWord8.fromString literal"
All 1 tests passed (0.00s)

Now apply an innocent patch:

$ git show d701a2a9a51da47da8240a7d3adf2794ba891e90
--- a/Data/ByteString/Lazy/Internal.hs
+++ b/Data/ByteString/Lazy/Internal.hs
+packBytes [] = Empty
 packBytes cs0 =
     packChunks 32 cs0
...
 packChars :: [Char] -> ByteString
+packChars [] = Empty
 packChars cs0 = packChunks 32 cs0

$ git cherry-pick d701a2a9a51da47da8240a7d3adf2794ba891e90
Auto-merging Data/ByteString/Lazy/Internal.hs

and rerun tests.

Expected results

Tests suceed both in GHC 8.10.4 and 9.0.1.

Actual results

Tests succeed in GHC 8.10.4, but fail in 9.0.1:

$ cabal run -w ghc-8.10.4 prop-compiled -- --hide-successes -p "LazyWord8.fromString literal"
All 1 tests passed (0.00s)
$ cabal run -w ghc-9.0.1 prop-compiled -- --hide-successes -p "LazyWord8.fromString literal"
All
  LazyWord8
    fromString literal: FAIL
      *** Failed! Falsified (after 1 test)

What surprises me most is that the failing test has no apparent connection to the patch in question:

  , testProperty "fromString literal" $
    fromString "\0\1\2\3\4" == B.pack [0,1,2,3,4]

See earlier discussion at https://github.com/haskell/bytestring/pull/394 CC @sjakobi @phadej

Edited by Bodigrim
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information