Closed JaSpa closed 1 year ago
This is expected behavior, from the Magic comments section in the README:
Note that for Ormolu to work the fragments where Ormolu is enabled must be parseable on their own.
For your example, Ormolu will format this snippet that preceeds the magic comment individually
{-
which is not parseable, which is exactly where the error message you are quoting is coming from.
In particular, this is not specific to multi-line comments; e.g. this will also fail to be formatted for the same reason:
test = 1 +
{- ORMOLU_DISABLE -}
2
With additional heuristics, Ormolu's magic comments could try to handle cases like these, but I currently think that the reduced predictability and significantly increased complexity are not worth it.
Does that clear it up?
Closing for now, feel free to reopen if needed.
Describe the bug The magic
{- ORMOLU_DISABLE -}
comment inside a multi-line comment trips up the parser. This came up when I wrapped a larger chunk of code inside a comment and formatting stopped working.To Reproduce Trying to format
results in
Expected behavior Unchanged output; changing the second line to
{- ORMOLU_DISAB -}
does not lead to a parse failure.Environment Tested with the current version of Ormolu Live: Version 0.5.1.0, commit 0bcf31c, using ghc-lib-parser 9.4.2.20220822