Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
cydparser opened this issue Oct 25, 2023 · 3 comments · Fixed by #380
Closed
3 tasks done

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

cydparser opened this issue Oct 25, 2023 · 3 comments · Fixed by #380
Labels
bug Something isn't working

Comments

@cydparser
Copy link

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.
@cydparser cydparser added the bug Something isn't working label Oct 25, 2023
@brandonchinn178
Copy link
Collaborator

brandonchinn178 commented Oct 25, 2023

Yes, the docs at https://fourmolu.github.io/config/column-limit say that column-limit might break idempotence. I can leave this up for now, but it's a semi-expected bug

@cydparser
Copy link
Author

The issue is more serious than idempotence: the formatted code cannot compile.

@brandonchinn178
Copy link
Collaborator

ah I see. Thanks for clarifying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants