tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

Ormolu incorrectly formats code with `-XOverloadedDot` #900

Closed ocharles closed 2 years ago

ocharles commented 2 years ago

Describe the bug Ormolu doesn't understand the significant of OverloadedDot and changes foo.bar into foo . bar, which changes the AST.

To Reproduce

Try and format

{-# language OverloadedDot #-}

test = hello.world

Expected behavior The semantics of OverloadedDot are respected, so hello.world remains unchanged.

Environment

Additional context No extra info.

amesgen commented 2 years ago

OverloadedDot is not a valid extension (see this list); Ormolu prints this exception:

  The GHC parser (in Haddock mode) failed:
  Unsupported extension: OverloadedDot

You probably mean OverloadedRecordDot, so the snippet

{-# language OverloadedRecordDot #-}

test = hello.world

is formatted to

{-# LANGUAGE OverloadedRecordDot #-}

test = hello.world

as expected.

Does that resolve your question?

ocharles commented 2 years ago

Sorry, I meant OverloadedRecordDot. I must be on an old version... let me do a bit more testing. Thank for the polite fast response, and sorry I haven't really done enough diligence in reporting this!

ocharles commented 2 years ago

Ok, I found the problem - on our master branch we use record-dot-preprocessor, and I have a branch that ports all this to OverloadedRecordDot. I accidentally did this testing on master (and obviously Ormolu struggles because it has no idea that there's a preprocessor) - on the actual OverloadedRecordDot branch all is good. Thanks again for the prompt reply, and sorry for wasting your time!

amesgen commented 2 years ago

No worries, there actually was some support for record-dot-preprocessor in Ormolu in the past, but we removed it when OverloadedRecordDot got into GHC.