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

multilines arrow expression enclosed in parenthesis format syntax error #1144

Closed
guibou opened this issue Nov 25, 2024 · 1 comment · Fixed by #1145
Closed

multilines arrow expression enclosed in parenthesis format syntax error #1144

guibou opened this issue Nov 25, 2024 · 1 comment · Fixed by #1145
Labels
bug Something isn't working

Comments

@guibou
Copy link

guibou commented Nov 25, 2024

Describe the bug

When trying to format a multiline arrow expression enclosed with parenthesis, ormolu generates an incorrect result.

To Reproduce

The following file:

{-# LANGUAGE Arrows #-}
import Control.Arrow

foo :: () -> ()
foo = proc () -> do
  (proc () -> 
    returnA -< ()
    ) -< ()

Calling ormolu -i on it leads to:

Bug.hs:9:3
  Parsing of formatted code failed:
  [GHC-58481] parse error (possibly incorrect indentation or mismatched brackets)

We can force the result to be written on disk, with ormolu -i -u, which leads to:

{-# LANGUAGE Arrows #-}

import Control.Arrow

foo :: () -> ()
foo = proc () -> do
  ( proc () ->
      returnA -< ()
  )
    -<
      ()

See how the parenthesis are aligned, which is incorrect. The file can be fixed by indenting by 1 space the closing space. I'm unsure about the details of the correct arrow syntax here.

Note that the arrow expression must be multiline to trigger this behavior.

Expected behavior

Ormolu should not fail to format on these arrows syntax.

Environment

  • OS name + version: linux nixos
  • Version of the code: ormolu 0.7.7.0

Additional context
Add any other context about the problem here.

@amesgen amesgen added the bug Something isn't working label Nov 25, 2024
@amesgen
Copy link
Member

amesgen commented Nov 25, 2024

Thanks! Fix is in #1145

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