haskell-github-trust / thyme

A faster date and time library based on time
BSD 3-Clause "New" or "Revised" License
46 stars 33 forks source link

Rewrite rule breaks code when used with ghc -O #58

Open relrod opened 7 years ago

relrod commented 7 years ago

I have the following code:

module Main where

import Data.Thyme.Time

main :: IO ()
main = print $ (realToFrac (150 :: NominalDiffTime) :: NominalDiffTime)

At first I thought it was a bug in GHC's optimizer, but then I saw the rewrite rules in Thyme and now I'm not sure where to file the bug, so I'm starting here. I'm able to reproduce this on GHC 8.0.1, 8.0.2, and 7.10.3.

Let me know if you need any more information, I'm happy to provide it or help test a fix.

relrod commented 7 years ago

BTW, if I use -ddump-simpl-stats, I see that the specific rule being fired is realToFrac/NominalDiffTime-Fractional

relrod commented 7 years ago

@liyang This creates a difference at runtime based on the level of optimization used with GHC - it's not caught during typechecking or anything, so I'm bumping this...

(I worked around it by figuring out how to get rid of the realToFrac call in my code entirely, but given how subtle the bug is, it might be good to get a fix out).

relrod commented 7 years ago

Bumping this again...

relrod commented 6 years ago

And again.

relrod commented 5 years ago

Yearly bump, but guessing this package just isn't maintained at this point.

relrod commented 3 years ago

Hm, missed last year. Yearly bump 2x.