[GHC] #16097: Bad error message for a misaligned case block in a do-let expression

GHC ghc-devs at haskell.org
Wed Dec 26 22:41:32 UTC 2018


#16097: Bad error message for a misaligned case block in a do-let expression
-------------------------------------+-------------------------------------
           Reporter:  kanetw         |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.6.2
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following code:

 {{{#!hs
 main = do
   code <- getCode
   let value = case code of
      1 -> 2
      3 -> 4
      _ -> 5
   print value
 }}}

 This is a parse error, as the indent of the case statements is under the
 indent introduced by let. However, the error message on 8.6 onwards is
 very misleading:

 {{{
 /home/dkr/example/Bad.hs:2:8: error:
     Unexpected do block in function application:
         do code <- getCode
            let value = ...
     You could write it with parentheses
     Or perhaps you meant to enable BlockArguments?
   |
 2 | main = do
   |        ^^...
 }}}

 Compare this with 8.4, which is a bit less bad:
 {{{
 /home/dkr/example/Bad.hs:5:6: error: parse error on input ‘1’
   |
 5 |      1 -> 2
   |      ^
 }}}

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


More information about the ghc-tickets mailing list