[GHC] #9581: Parse error in multiline case expression inside let inside do block

#9581: Parse error in multiline case expression inside let inside do block -------------------------------------+------------------------------------- Reporter: mpopov | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Keywords: | Operating System: Linux Architecture: Unknown/Multiple | Type of failure: GHC Difficulty: Unknown | rejects valid program Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- {{{#!hs main = do let x = case 1 of 0 -> False _ -> True print x }}} The above program produces the following error: $ runghc bug.hs bug.hs:3:11: parse error on input ‘->’ Slightly rewritten versions print True as indended: {{{#!hs main = do let x = case 1 of { 0 -> False; _ -> True } print x main = do print $ case 1 of 0 -> False _ -> True }}} I have double-checked that the offending program does not contain mixed tabs and spaces. The same error occurs on my own system (Linux Mint x64, Haskell Platform 2014.2 with GHC 7.83) and in FPComplete's online IDE. I first encountered the error in a program copied verbatim from a Haskell book, so i assume that the syntax is allowed. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9581 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9581: Parse error in multiline case expression inside let inside do block -------------------------------------+------------------------------------- Reporter: mpopov | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 Resolution: invalid | Keywords: Operating System: Linux | Architecture: Unknown/Multiple Type of failure: GHC | Difficulty: Unknown rejects valid program | Blocked By: Test Case: | Related Tickets: Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => invalid Comment: This program isn't valid. `let` introduces layout, so because line 3's first non-whitespace character is in the same column as the first non- whitespace character after the `let`, lines 2-4 desugar to {{{ let { x = case 1 of {}; 0 -> False; _ -> True }; }}} Lines 3 and 4 need to be indented by at least one more space for the intended meaning. (It may help to recall that {{{ main = do let x = 1 y = 2 print x }}} is valid syntax.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9581#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC