[GHC] #9042: List indenting in case fails

#9042: List indenting in case fails ------------------------------------+------------------------------------- Reporter: laar | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- The following code fails to parse {{{ module Temp where t = case [1..2] of [ 1 , 2 ] -> True _ -> False }}} with {{{ Temp.hs:5:9: parse error (possibly incorrect indentation or mismatched brackets) }}} Which relates to the line `, 2`. Indenting both that line and the next one is needed to parse the module. This is contrary to what I suspected. As this vertical layout for lists is allowed as expression, I would also expect it to work for patterns. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9042 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9042: List indenting in case fails -------------------------------------+------------------------------------ Reporter: laar | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Changes (by goldfire): * status: new => closed * resolution: => invalid Comment: I would say GHC's behavior in this case is correct. According to (my understanding of) the layout rule, the first character after a layout herald (the `of`, in your case) sets the new indentation level (provided it is not too far left!). So, your open-bracket sets the indentation level. Then, your comma is at the same level of indentation, so GHC inserts a `;` before the comma, causing the parse error. So, that syntax ''is'' available in patterns, as witness by the following (accepted) code: {{{ t = case Just [1..2] of Just [ 1 , 2 ] -> True _ -> False }}} In this example, the `J` of the `Just` in the pattern sets the indentation level, so there's no problem laying out the list vertically. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9042#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC