Skip to content

Strings containing \^\ escape sequence are misformatted #1165

Open
@amesgen

Description

@amesgen

Describe the bug

Consider the string literal

"\^\ "

It represents a string literal with two characters: the first one is a file separator character1, and the second one is a space character.

However, we do not handle it incorrectly, due to our logic for string gaps.

  • With Ormolu 0.7.7.0 and older, it is formatted (with --unsafe) to

    "\^

    (note the missing closing "!).

  • With Ormolu 0.8.0.0, GHC fails to parse the input in the first place. This is an upstream bug (#25937), scheduled to be fixed in GHC 9.12.3.

Expected behavior
The input above should not cause any errors and be a fixed point.

Additional context
I think it makes sense to wait with fixing this until GHC 9.12.3 has been released with the fix for #25937 as mentioned above.

Footnotes

  1. This syntax is quite obscure, see e.g. Table B.3 here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug-upstreamSomething upstream is not working.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions