[GHC] #14008: NondecreasingIndentation is problematic when the indentation can't be decreased

GHC ghc-devs at haskell.org
Sat Jul 22 05:11:50 UTC 2017


#14008: NondecreasingIndentation is problematic when the indentation can't be
decreased
-------------------------------------+-------------------------------------
           Reporter:  allbery_b      |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  low            |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  Poor/confusing
  Unknown/Multiple                   |  error message
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Consider the following program, which was deliberately mis-indented
 (someone playing with an exercise with deliberate errors and being
 confused by the result):

 {{{#!hs
 module Print3Broken where

 printSecond :: IO ()
 printSecond = do
 putStrLn greeting -- Yarrrrr out of scope

 main :: IO ()
 main = do
   putStrLn greeting
   printSecond
   where greeting = "Yarrrrr"
 }}}

 With `-XNondecreasingIndentation` on by default, this will parse as long
 as the definition of `main` (or any other definition) is not present after
 the `do` block. But there is no legal way to have a definition after the
 `do` because it is not possible to unindent from column 1 --- and the
 resulting parse error is a bit confusing and gives no hint that
 `NondecreasingIndentation` applied to the `do` is the cause.

 I suspect `NondecreasingIndentation` should not be applied when it is
 impossible to decrease the indentation.

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


More information about the ghc-tickets mailing list