Permalink
Browse files

Handle signed size parameter of J# constructor correctly

This fixes bug #68.
  • Loading branch information...
1 parent 4ce176b commit dcdf6ab5b93189c74bbcbb01396c634b6a3628c0 @bos committed Jun 3, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 Data/Hashable/Class.hs
View
@@ -276,10 +276,12 @@ hash64 salt = fromIntegral . c_wang64 . xor (fromIntegral salt) . fromIntegral
instance Hashable Integer where
#if defined(__GLASGOW_HASKELL__) && defined(VERSION_integer_gmp)
hashWithSalt salt (S# int) = hashWithSalt salt (I# int)
- hashWithSalt salt n@(J# size byteArray)
+ hashWithSalt salt n@(J# size# byteArray)
| n >= minInt && n <= maxInt = hashWithSalt salt (fromInteger n :: Int)
- | otherwise = let numBytes = SIZEOF_HSWORD * (I# size)
+ | otherwise = let size = I# size#
+ numBytes = SIZEOF_HSWORD * abs size
in hashByteArrayWithSalt byteArray 0 numBytes salt
+ `hashWithSalt` size
where minInt = fromIntegral (minBound :: Int)
maxInt = fromIntegral (maxBound :: Int)
#else

0 comments on commit dcdf6ab

Please sign in to comment.