[GHC] #10884: Indentation requirements for parsing seem inconsistent

#10884: Indentation requirements for parsing seem inconsistent -------------------------------------+------------------------------------- Reporter: Samvh | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Keywords: parsing, | Operating System: Unknown/Multiple indentation, do-notation | Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Revisions: | -------------------------------------+------------------------------------- The "golden rule of indentation" does not seem to be strictly adhered to in all cases: there is an interaction between let/where clauses and do- notation that makes indentation requirements different in different situations: Example 1, parsed successfully: {{{#!hs f = let y = do Just 1 in y }}} Example 2, causes an error: {{{#!hs f = let y = Just 1 in y }}} Example 3, causes an error: {{{#!hs f = do Just 1 }}} This behavior seems inconsistent to me. See also [http://stackoverflow.com/questions/32531508/haskell-parse-error- from-incorrect-indent]. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10884 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#10884: Indentation requirements for parsing seem inconsistent -------------------------------------+------------------------------------- Reporter: Samvh | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Compiler | Version: 7.10.2 (Parser) | Keywords: parsing, Resolution: invalid | indentation, do-notation Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by ezyang): * status: new => closed * resolution: => invalid Comment: This is due to `NonDecreasingIndentation`, which is not per Haskell98 but useful in cases where you want to open a do-block without increasing indentation. This will parse fail: {{{ {-# LANGUAGE NoNondecreasingIndentation #-} f = let y = do Just 1 in y }}} Non-decreasing indentation doesn't work at the top level, because if you applied it there, there would be no indentation you could drop back in order to get out of a do-block. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10884#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC