Skip to content

mod (i :: Word8) 7 sometimes results in values like 22 or 219

git clone git@github.com:haskellari/binary-instances.git
cd binary-instances
git checkout ghc-9.12
cabal run binary-instances-test -w ghc-9.12.1 -- -p DayOfWeek
Configuration is affected by the following files:
- cabal.project
Roundtrip
  DayOfWeek: FAIL
    *** Failed! Exception: 'panic: get @DayOfWeek: (5,181)' (after 1 test):
    Friday
    Exception thrown while showing test case: 'panic: get @DayOfWeek: (5,181)'
    Use --quickcheck-replay="(SMGen 330261610994565626 12834802228157555811,0)" to reproduce.

1 out of 1 tests failed (0.00s)

The code of the test is running get @DayOfWeek which is

    get = do
        i <- get
        return $ case mod (i :: Word8) 7 of
            0 -> Time.Sunday
            1 -> Time.Monday
            2 -> Time.Tuesday
            3 -> Time.Wednesday
            4 -> Time.Thursday
            5 -> Time.Friday
            6 -> Time.Saturday
            j -> error $ "panic: get @DayOfWeek: " ++ show (i, j)

I don't understand how the default case is reached. This happens every run.

It never happens with other GHC versions I tried, e.g. ghc-9.10.1 or 9.6.6.

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