[GHC] #15705: Confusing parser error in 8.6

GHC ghc-devs at haskell.org
Thu Oct 4 16:21:03 UTC 2018


#15705: Confusing parser error in 8.6
-------------------------------------+-------------------------------------
           Reporter:  diatchki       |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:  8.6.1
          Component:  Compiler       |           Version:  8.6.1
  (Parser)                           |
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Incorrect
  Unknown/Multiple                   |  error/warning at compile-time
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following example:
 {{{
 f x =
   case x of
     A -> 'a'
    B -> 'b'
 }}}

 The problem here is that `B` is misaligned, which is quite a common
 mistake, especially in a bigger case block.

 GHC reports the following error:
 {{{
     Unexpected case expression in function application:
         case x of { A -> 'a' }
     You could write it with parentheses
     Or perhaps you meant to enable BlockArguments?
 }}}
 This is quite confusing, especially since the program won't parse,
 `BlockArguments` or not.   My guess is that we are being a bit too eager
 with reporting the `BlockArguments` issue.

 One way to work around this would be to just remember if we used
 `BlockArguments` while parsing, but only do the check that the extension
 is enabled after a successful parse.

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


More information about the ghc-tickets mailing list