logo       

PackedString.hGetPS produces index exception: msg#00034

lang.haskell.glasgow.bugs

Subject: PackedString.hGetPS produces index exception

Why does the attached function psTest, for ghc5.04.3 on Linux, produce the
error:
*** Exception: Ix{Int}.index: Index (30000) out of range ((0,29999))

module PS where

import IO
import Data.PackedString

psTest =
do
f <- openFile "psTest" WriteMode
let
s1 = "abc"
s2 = take 30000 (cycle "k")

hPutPS f (packString s1)
hPutPS f (packString s2)
hClose f

g <- openFile "psTest" ReadMode
ch1 <- hGetChar g
ch2 <- hGetChar g
ch3 <- hGetChar g
ps2 <- hGetPS g (length s2)
putStrLn (show (unpackPS ps2 == s2))
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise