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

Trouble formatting data declaration where there is no space between field name and :: #488

Open
andremarianiello opened this issue Dec 12, 2024 · 0 comments

Comments

@andremarianiello
Copy link

andremarianiello commented Dec 12, 2024

(moved from haskell/haskell-language-server#4466)

Behavior summary by stylish-haskell version(s):

  • 0.14.6.0 - Main.hs: <string>:5:6: error: parse error on input :'`
  • 0.13.0.0 - Main.hs: RealSrcSpan SrcSpanOneLine "Main.hs" 5 6 7: parse error on input :'`
  • 0.12.0.0 - Main.hs: RealSrcSpan SrcSpanOneLine "Main.hs" 5 6 7: parse error on input :'`
  • 0.11.0.0 - Language.Haskell.Stylish.Parse.parseModule: could not parse Main.hs: ParseFailed (SrcLoc "<unknown>.hs" 5 6) "Parse error: :"
  • 0.10.0.0 - Successful parse and formatting!

Steps to reproduce

Format
Main.hs:

main = pure ()

data MyRecord = MyRecord
  { ab :: Int
  , c:: Int
  }

with stylish-haskell Main.hs

Important pieces here:

  • c:: Int <- no space between field name and ::. This makes the formatting fail.
  • ab field name is longer than c field name. This makes the error show up in the LSP log. If the fields are the same length no error appears, but the formatting still fails to apply. Weird!

Expected behaviour

Since this code compiles with ghc Main.hs I would expect it to be formatted with stylish-haskell Main.hs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant