Skip to content

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

@andremarianiello

Description

@andremarianiello

(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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions