-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: make formatter use current token table (#5389)
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 ```lean 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`.
- Loading branch information
Showing
2 changed files
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/-! | ||
# Verify that the formatter uses the current token table | ||
Formerly, the formatter was only looking at the builtin token table | ||
when deciding where to insert additional whitespace between tokens. | ||
This lead to `5+' -1` in the following pretty printing as `5+'-1`. | ||
-/ | ||
|
||
infixl:65 "+'" => Int.add | ||
notation:65 a:65 "+'-" b:66 => Int.add a (id b) | ||
|
||
/-- info: 5+' -1 : Int -/ | ||
#guard_msgs in #check 5 +' -1 | ||
|
||
/-- info: 5+'-1 : Int -/ | ||
#guard_msgs in #check 5 +'- 1 |