Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Handle signed size parameter of J# constructor correctly

This fixes bug #68.
  • Loading branch information...
commit dcdf6ab5b93189c74bbcbb01396c634b6a3628c0 1 parent 4ce176b
@bos authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 Data/Hashable/Class.hs
View
6 Data/Hashable/Class.hs
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.