PackedString.hGetPS produces index exception

George Russell ger at tzi.de
Tue Apr 15 14:29:04 EDT 2003


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))

-------------- next part --------------
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))


More information about the Glasgow-haskell-bugs mailing list