[Haskell-cafe] Bug in writeArray?
Grzegorz Chrupała
pitekus at gmail.com
Wed Sep 23 11:19:59 EDT 2009
Hi all,
This seems like a bug in the implementation of writeArray: when passed
an out-of-range index it silently writes to an incorrect index in the
array.
--
import Data.Array.IO
import Data.Array.Unboxed
main = do
let (l,u) = ((0,10),(20,20))
marr <- newArray (l,u) 0 :: IO (IOUArray (Int,Int) Int)
let badi = (10,9)
print (inRange (l,u) badi)
writeArray marr badi 1
arr <- freeze marr :: IO (UArray (Int,Int) Int)
print . filter ((/=0) . snd) . assocs $ arr
--
Grzegorz
More information about the Haskell-Cafe
mailing list