[GHC] #8106: Confusing parse error for missing do keyword

GHC ghc-devs at haskell.org
Wed Jul 31 22:49:03 CEST 2013


#8106: Confusing parse error for missing do keyword
-------------------------------------+--------------------------
       Reporter:  mhitza             |             Owner:
           Type:  bug                |            Status:  new
       Priority:  low                |         Milestone:
      Component:  Compiler (Parser)  |           Version:  7.6.3
       Keywords:                     |  Operating System:  Linux
   Architecture:  x86_64 (amd64)     |   Type of failure:  Other
     Difficulty:  Unknown            |         Test Case:
     Blocked By:                     |          Blocking:
Related Tickets:                     |
-------------------------------------+--------------------------
 {{{
 import Control.Monad (when)

 main = do
     when (True == True) $
         x <- getLine
         print "y"
 }}}

 This piece of code is missing the `do` keyword before the block, yet the
 error message that is returned is:

 {{{
 poc.hs:4:11: Parse error in pattern: True == True
 }}}

 Yet the next variant provides a bit more helpful information

 {{{
 import Control.Monad (when)

 main = do
     when (True == True) $
         print "x"
         print "y"
 }}}


 {{{
 poc.hs:5:9:
     Couldn't match expected type `(a0 -> IO ()) -> [Char] -> m0 ()'
                 with actual type `IO ()'
     The function `print' is applied to three arguments,
     but its type `[Char] -> IO ()' has only one
     In the second argument of `($)', namely `print "x" print "y"'
     In a stmt of a 'do' block:
       when (True == True) $ print "x" print "y"
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8106>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler




More information about the ghc-tickets mailing list