Skip to content

Fix rendering of regular record updates with RDP enabled#706

Merged
mrkkrp merged 1 commit intotweag:masterfrom
davidmrt98:rdp-idempotency-bug
May 13, 2021
Merged

Fix rendering of regular record updates with RDP enabled#706
mrkkrp merged 1 commit intotweag:masterfrom
davidmrt98:rdp-idempotency-bug

Conversation

@davidmrt98
Copy link
Copy Markdown
Contributor

Closes #701.

This pull request solves the "second half" of the idempotency bug presented in #701, but there is a another bug (the "first half") for which I do not see an obvious solution. Since the other bug is not directly related to this, I've opened a separate Issue where I explain the problem in detail, see #705.

When Ormolu checks if a record update conforms to the RDP syntax (no space before the opening brace), it compares the column numbers of the relevant source spans but not the line numbers. This is why a regular record update of the form

{-# OPTIONS_GHC -fplugin=RecordDotPreprocessor #-}

def 
  { g = 1 
  }

where the start / end columns of the expression def and the field g are aligned in a specific way, "tricks" Ormolu into thinking that this is an RDP record update, even when it is clearly not. The formatting result looks like this:

{-# OPTIONS_GHC -fplugin=RecordDotPreprocessor #-}

def{g = 1
   }

For the same reason the second code snippet from #701 gets formatted the way it is. Fortunately, the problem is simply solved by checking if the relevant source spans are on the same line.

@mrkkrp mrkkrp merged commit 7f79473 into tweag:master May 13, 2021
@mrkkrp
Copy link
Copy Markdown
Member

mrkkrp commented May 13, 2021

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record updates with RDP are not idempotent

2 participants