#984: Syntax error shows in the wrong position
----------------------------------+-----------------------------------------
 Reporter:  guest                 |          Owner:          
     Type:  bug                   |         Status:  new     
 Priority:  low                   |      Milestone:  _|_     
Component:  Compiler (Parser)     |        Version:  6.4.2   
 Severity:  minor                 |     Resolution:          
 Keywords:  syntax parse case do  |     Difficulty:  Unknown 
 Testcase:                        |   Architecture:  Multiple
       Os:  Multiple              |  
----------------------------------+-----------------------------------------
Changes (by simonmar):

  * architecture:  x86 => Multiple
  * milestone:  => _|_
  * severity:  normal => minor
  * priority:  normal => low
  * os:  Linux => Multiple

Comment:

 In a sense, GHC is telling you something completely sensible here, but it
 wasn't what you were expecting.  Let me add some parentheses to your code:

 {{{
 f _ = do
         x <- computation
         (case () of
                 _ ->
                         result) <- computation
                         case () of () -> undefined
 }}}

 See now?  You've written a binding statement (`pattern <- expr`), where
 the pattern is in fact a case expression, so GHC complains that the case
 expression is not a valid pattern.  Indeed, if you use `-ferror-spans`,
 you'll see that the span of the error covers the parenthesised case
 expression.

 It might be difficult for us to do anything better here.  We kind-of want
 the case expression to eliminate the possibility of a binding statement
 from the parser, but there's no easy way to do that in GHC's parser.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/984>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to