Skip to content

Parse error on a standalone declaration with an associated Haddock #480

@DavSanchez

Description

@DavSanchez

Hello! I'm in the process of adding ormolu support to HIE, but I have doubts with the way ormolu seems to handle formatting just a selection inside a file, or if it's even advisable!

For the moment the local tests appear to be working when formatting the whole file on save. I'm testing with the files that ormolu provides as examples.

However, when trying to format just a segment of the whole file I get some errors, but they seem a bit erratical (in some segments the formatting works, in others doesn't, in others it seems to work but then trying to format the whole file fails, as the indentation was messed up in the process).

For example, let's try with the selection made in this file (please ignore the red wiggles):

image

If I format the whole file it works without a problem. For the selection made, I think this would be the expected output:

image

When trying with Format Selection, it complains the following (emphasis mine):

[Error - 2:59:07 PM] Request textDocument/formatting failed.
Message: ormoluCmd: OrmoluParsingFailed (RealSrcSpan SrcSpanOneLine "/Users/David/Desktop/ormolu-tests/examples/declaration/class/associated-data2.hs" 16 5 9) "parse error on input `data'"
Code: -32603

As said, if I select other segments it works, but sometimes it will break the indentation of the files, preventing the formatting of the whole file to work correctly after that.

As I think these errors have more to do with ormolu than with HIE I have opened the issue here. Maybe this is the expected behaviour and it is discouraged to try formatting file selections?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug-upstreamSomething upstream is not working.commentsIssues related to comment placementneeds-ghc-patchTo solve this issue we need to patch GHC

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions