lean4-htt/tests/lean/run/formatterTokenTable.lean
Kyle Miller 1129160d80
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`.
2024-09-24 05:33:12 +00:00

16 lines
456 B
Text

/-!
# 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