[GHC] #9327: possibly incorrect indentation or mismatched brackets

#9327: possibly incorrect indentation or mismatched brackets -------------------------------------+------------------------------------- Reporter: Jefffrey | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Differential Revisions: Operating System: MacOS X | Architecture: Type of failure: Incorrect | Unknown/Multiple warning at compile-time | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------- I'm having a weird problem. This code compiles: {{{ fetchSomething :: IO String fetchSomething = return "Something" main :: IO () main = do if True then do l <- fetchSomething let fn s = do let rs = s ++ ": " l <- fetchSomething return $ rs ++ l n <- fn "Prefix" putStr n else return () }}} but the following doesn't: {{{ let ep = Bridge.destination b > e ed <- doesDirectoryExist ep if ed then do ds <- listDirs ep let fn p = do let t = readUTC p lt <- toLocalTime t <-- parse error (possibly incorrect indentation or mismatched brackets) return $ Snapshot t lt e b l <- mapM fn ds let r = sortBy (compare `on` time) l let ri = Prelude.take m $ assignIDs 1 r if o == Oldest then return $ ri else return $ reverse ri else return [] }}} Here's a live demo of the former: http://coliru.stacked- crooked.com/a/0305f546c8566683 To test the second, the only way I could find is by downloading this repository: https://github.com/Jefffrey/Kopia/commit/9ec9eb93183c4ceed6d324f7fc726584de0... and running `cabal test`. Someone on the #haskell channel reproduced it on his machine too. This seems like a bug. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9327 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9327: possibly incorrect indentation or mismatched brackets -------------------------------------+------------------------------------- Reporter: Jefffrey | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Resolution: | Keywords: Differential Revisions: | Operating System: MacOS X Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Comment (by Jefffrey): The person that tested it on his machine states he is running it on GHC 7.8. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9327#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9327: possibly incorrect indentation or mismatched brackets -------------------------------------+------------------------------------- Reporter: Jefffrey | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Resolution: invalid | Keywords: Differential Revisions: | Operating System: MacOS X Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => closed * resolution: => invalid Comment: You are doing something very weird here, mixing two different levels of indentation. I think you probably want {{{ let ep = Bridge.destination b > e ed <- doesDirectoryExist ep if ed then do ds <- listDirs ep let fn p = do -- The following three lines are part of the 'do' -- They are not new binding in the 'let', peer to 'fn' let t = readUTC p lt <- toLocalTime t return $ Snapshot t lt e b l <- mapM fn ds let r = sortBy (compare `on` time) l let ri = Prelude.take m $ assignIDs 1 r if o == Oldest then return $ ri else return $ reverse ri else return [] }}} If in doubt, use braces and semi-colons: {{{ let ep = Bridge.destination b > e ed <- doesDirectoryExist ep if ed then do { ds <- listDirs ep ; let fn p = do -- The following three lines are part of the 'do' -- They are not new binding in the 'let', peer to 'fn' { let t = readUTC p ; lt <- toLocalTime t ; return $ Snapshot t lt e b } ; l <- mapM fn ds ; let r = sortBy (compare `on` time) l ; let ri = Prelude.take m $ assignIDs 1 r ; if o == Oldest then return $ ri else return $ reverse ri } else return [] }}} Simon -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9327#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9327: possibly incorrect indentation or mismatched brackets -------------------------------------+------------------------------------- Reporter: Jefffrey | Owner: Type: bug | Status: closed Priority: low | Milestone: Component: Compiler | Version: 7.6.3 Resolution: invalid | Keywords: Differential Revisions: | Operating System: MacOS X Architecture: | Type of failure: Incorrect Unknown/Multiple | warning at compile-time Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | -------------------------------------+------------------------------------- Comment (by rwbarton): Actually, both snippets are valid with the NondecreasingIndentation language extension, which is on by default but off when the Haskell2010 language extension is chosen—which it is in the Test-Suite stanza of Kopia.cabal. So everything is working as expected here. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9327#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC