lspitzner / brittany

haskell source code formatter
GNU Affero General Public License v3.0
690 stars 72 forks source link

brittany gives an error if code in a module is indented #137

Closed sharno closed 6 years ago

sharno commented 6 years ago

I'm using brittany through the Haskell Language Server plugin in VSCode and I was trying to format this code

module Jammin
where

  data Fruit = Peach
    | Plum
    | Apple
    | Blackberry deriving (Eq, Show, Ord)
  data JamJars = Jam {fruit::Fruit, num::Int} deriving (Eq, Show, Ord)
  row1, row2, row3, row4, row5, row6 :: JamJars
  row1 = Jam Plum 1
  row2 = Jam Blackberry 9
  row3 = Jam Apple 12
  row4 = Jam Blackberry 10
  row5 = Jam Peach 32
  row6 = Jam Apple 4

  allJam :: [JamJars]
  allJam = [row1, row2, row3, row4, row5, row6]

it gives me this error in the output of the plugin:

[Error - 10:42:55 AM] Request textDocument/formatting failed.
  Message: IdeError {ideCode = PluginError, ideMessage = "brittanyCmd: Brittany error - invalid output\n", ideInfo = Null}
  Code: -32603 

Removing the indentation of all the code after where makes it work again although the it was valid code with indentation

lspitzner commented 6 years ago

Closing as duplicate of #81 (whose title i just clarified a bit).

Thanks for the report. This is indeed a case that simply is not handled correctly yet and that should be fixed.