Serious Data.HashTable bug
|Reported by:||jwr@…||Owned by:|
|Type of failure:||Test Case:|
|Related Tickets:||Differential Revisions:|
The program below illustrates a difference between the description of the semantics of insert (given below) and the implementation. Try calling the function "test" with values greater than 2047. For instance:
HT> test 2048 0 1024
The documentation states: insert :: HashTable key val -> key -> val -> IO ()
Inserts an key/value mapping into the hash table.
Note that insert doesn't remove the old entry from the table
- the behaviour is like an association list, where lookup returns
the most-recently-inserted mapping for a key in the table. The reason for this is to keep insert as efficient as possible. If you need to update a mapping, then we provide update.
module HT where import Data.HashTable import qualified Data.HashTable as HT test :: Int -> IO () test n = do ht <- new (==) hashInt sequence_ [ insert ht key 0 | key <- [0..n]] sequence_ [ insert ht key 1 | key <- [0..n]] let check key = do (Just val) <- HT.lookup ht key if val==1 then return () else putStrLn $ show key sequence_ [ check key | key <- [0..n]]
Change History (6)
comment:3 Changed 10 years ago by simonmar
- Resolution set to fixed
- Status changed from new to closed