[GHC] #9711: Confusing errors when compiling text-1.2.0.0

#9711: Confusing errors when compiling text-1.2.0.0 ----------------------------------+--------------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: MacOS X Architecture: x86_64 (amd64) | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: ----------------------------------+--------------------------------------- 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: {{{#!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 {{{#!hs | 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 {{{#!hs | x == '\n' -> do n1 <- writeCharBuf raw n '\r' writeCharBuf raw n1 '\n' >>= inner s' }}} then it compiles them too! Again, with context, look carefully: {{{#!hs 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. {{{#!hs 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 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Comment (by rwbarton): This seems rather hard to believe. I get those exact errors (down to the column numbers) when I remove three spaces after `x == '\n'` (like in your last snippet) ''only''. Are you sure you haven't edited this file before trying to build it, possibly inserting tab characters in the process? I guess it's possible that the homebrew build is somehow faulty in a way that would cause this, but difficult to imagine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Comment (by rwbarton): Ohh wait, perhaps it is a CPP issue. (Though I can't make sense of it if so.) I forget what the solution to CPP issues on OS X is, but I think it might be "don't use homebrew, download the binary distribution from haskell.org". -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Comment (by rwbarton): Does it make any difference if you remove `CPP, ` from line 1 and remove lines 2 and 4? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Comment (by asvyazin): Actually, yes, it does... After removing CPP stuff there are no errors. It looks like CPP somehow "eats" extra spaces and breaks indentation. I will try binary version from haskell.org later -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Comment (by asvyazin): Yes, binary version from haskell.org works fine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9711: Confusing errors when compiling text-1.2.0.0 ---------------------------------------+---------------------------------- Reporter: asvyazin | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: invalid | Keywords: Operating System: MacOS X | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | ---------------------------------------+---------------------------------- Changes (by asvyazin): * status: new => closed * resolution: => invalid -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9711#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC