Skip to content

BlockArguments combined with column-limit can result in an error #377

@cydparser

Description

@cydparser

Is your bug specific to Fourmolu?

  • Yes, I've verified that Ormolu does not have this bug

Did you try it on the web app?

Did you search for existing issues?

  • Yes, there are no open or closed issues related to my issue

Describe the bug

Long lines that use BlockArguments cause an error when formatted using a column-limit that is less than the length of the line. I noticed this bug when formatting Hspec tests (e.g. it "foo" do).

A minimal example:

{-# LANGUAGE BlockArguments #-}

putThen :: String -> IO a -> IO a
putThen s action =
  putStrLn s >> action

main :: IO ()
main = do
  putThen "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" do
    putStrLn ""

Results in:

<stdin>
@@ -7,4 +7,5 @@
  main :: IO ()
  main = do
-   putThen "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" do
+   putThen
+   "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" do
      putStrLn ""

  AST of input and AST of formatted code differ.
    at <stdin>:(9,3)-(10,15)
  Please, consider reporting the bug.
  To format anyway, use --unsafe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions