Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make formatter use current token table #5389

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Sep 18, 2024

Previously the formatter was using the builtin token table rather that the one in the current environment. This could lead to round-tripping failures for user-defined notations.

For an illustrative example, given the following notation

infixl:65 "+'" => Int.add
notation:65 a:65 "+'-" b:66 => Int.add a (id b)

then 5 +' -1 would parse as Int.add 5 (-1) and incorrectly pretty print as 5+'-1, which in turn would parse as Int.add 5 (id 1). Now it pretty prints as 5+' -1.

Previously the formatter was using the builtin token table rather that the one in the current environment. This could lead to round-tripping failures for user-defined notations.

For an illustrative example, given the following notation
```lean4
infixl:65 "+'" => Int.add
notation:65 a:65 "+'-" b:66 => Int.add a (id b)
```
then `5 +' -1` would parse as `Int.add 5 (-1)` and incorrectly pretty print as `5+'-1`. However, this parses as `Int.add 5 (id 1)`.
@kmill kmill requested a review from Kha as a code owner September 18, 2024 23:36
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Sep 19, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Sep 19, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Sep 19, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@kmill kmill added this pull request to the merge queue Sep 24, 2024
Merged via the queue into leanprover:master with commit 1129160 Sep 24, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builds-mathlib CI has verified that Mathlib builds against this PR toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants