-
Notifications
You must be signed in to change notification settings - Fork 185
Data.JSString.Int.decimal
crashes on large Word64
.
#570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm a bit less confused now: it can be reproduced on the tip of branch ghc-8.0. If you change |
I've written a import Prelude hiding (reverse, take, dropWhile)
import Data.JSString
import Data.JSString.Int
import Data.Monoid
import Data.Word
import GHC.Fingerprint
main :: IO ()
main = do
test [16555890932631501216, 6555890932631501216]
print (decimal (16555890932631501216 :: Word64)) -- crashes
test :: [Word64] -> IO ()
test [] = pure ()
test (w:ws) = do
print w
print (decimal_workaround_570 w)
test ws
-- | See https://github.com/ghcjs/ghcjs/issues/570 for details.
decimal_workaround_570 :: Word64 -> JSString
decimal_workaround_570 w = dropleadingzeros . mconcat $ showpadded <$> chunks
where
n = 10^5
chunks :: [Integer]
chunks =
[ (fromIntegral w `div` n^3) `mod` n
, (fromIntegral w `div` n^2) `mod` n
, (fromIntegral w `div` n) `mod` n
, fromIntegral w `mod` n
]
showpadded :: Integer -> JSString
showpadded i = reverse . take 5 . reverse $ pack "00000" <> decimal i
dropleadingzeros :: JSString -> JSString
dropleadingzeros = dropWhile (== '0') |
I wonder if this is closed in https://github.com/zerobuzz/ghcjs-stack-dist/raw/master/ghcjs-0.2.1.9008011.tar.gz? |
I can still see it with the latest version. Looks like a bug in either one of the |
found the problem, fix coming |
fix in |
Uh oh!
There was an error while loading. Please reload this page.
Build the following bit of code and run it in node:
Output
I have seen this happen on resolver-7.13, resolver-7.1, resolver-7.19, and
(I think)one6ad1f231cebf9but I have also seen it not to happen on 7.13.Is it possible that I have to do more thanstack clean
in my project between changes of compiler version?Thanks!
The text was updated successfully, but these errors were encountered: