Skip to content
Snippets Groups Projects
Commit b35eed2a authored by Alex Biehl's avatar Alex Biehl Committed by GitHub
Browse files

Haddock: Fix broken lazy IO in prologue reading (#615)

We previously used withFile in conjunction with hGetContents. The list returned
by the latter wasn't completely forced by the time we left the withFile block,
meaning that we would try to read from a closed handle.
parent d300632c
No related branches found
No related tags found
No related merge requests found
......@@ -547,9 +547,10 @@ getPrologue :: DynFlags -> [Flag] -> IO (Maybe (MDoc RdrName))
getPrologue dflags flags =
case [filename | Flag_Prologue filename <- flags ] of
[] -> return Nothing
[filename] -> withFile filename ReadMode $ \h -> do
[filename] -> do
h <- openFile filename ReadMode
hSetEncoding h utf8
str <- hGetContents h
str <- hGetContents h -- semi-closes the handle
return . Just $! parseParas dflags str
_ -> throwE "multiple -p/--prologue options"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment