Confusing errors when compiling text-1.2.0.0
I was trying to install text-1.2.0.0 on my system (Mac OS X 10.7.5 Lion) through cabal (cabal-install-1.20.0.3, cabal-1.20.0.2) and got some compile errors: [29 of 43] Compiling Data.Text.IO ( Data/Text/IO.hs, dist/build/Data/Text/IO.o )
Data/Text/IO.hs:236:29:
The last statement in a 'do' block must be an expression
n1 <- writeCharBuf raw n '\r' writeCharBuf raw n1 '\n' >>= inner s'
Data/Text/IO.hs:237:49:
Not in scope: ‘n1’
Perhaps you meant one of these: ‘n’ (line 230), ‘s1’ (line 228)
Let's see what we have at 236 line of Data/Text/IO.hs:
writeBlocksCRLF :: Handle -> Buffer CharBufElem -> Stream Char -> IO ()
writeBlocksCRLF h buf0 (Stream next0 s0 _len) = outer s0 buf0
where
outer s1 Buffer{bufRaw=raw, bufSize=len} = inner s1 (0::Int)
where
inner !s !n =
case next0 s of
Done -> commit n False{-no flush-} True{-release-} >> return ()
Skip s' -> inner s' n
Yield x s'
| n + 1 >= len -> commit n True{-needs flush-} False >>= outer s
| x == '\n' -> do n1 <- writeCharBuf raw n '\r' -- 236 line is here!!!
writeCharBuf raw n1 '\n' >>= inner s'
| otherwise -> writeCharBuf raw n x >>= inner s'
commit = commitBuffer h raw len
Seems legit… And if I rewrite this two lines as
| x == '\n' -> do n1 <- writeCharBuf raw n '\r'; writeCharBuf raw n1 '\n' >>= inner s'
then ghc compiles them fine. Even more interesting - if I rewrite this lines as
| x == '\n' -> do n1 <- writeCharBuf raw n '\r'
writeCharBuf raw n1 '\n' >>= inner s'
then it compiles them too! Again, with context, look carefully:
Yield x s'
| n + 1 >= len -> commit n True{-needs flush-} False >>= outer s
| x == '\n' -> do n1 <- writeCharBuf raw n '\r'
writeCharBuf raw n1 '\n' >>= inner s'
| otherwise -> writeCharBuf raw n x >>= inner s'
doesn't work.
Yield x s'
| n + 1 >= len -> commit n True{-needs flush-} False >>= outer s
| x == '\n' -> do n1 <- writeCharBuf raw n '\r'
writeCharBuf raw n1 '\n' >>= inner s'
| otherwise -> writeCharBuf raw n x >>= inner s'
works! Weird…
P.S. GHC version 7.8.3, installed through homebrew
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |