feat: make loose fvars pretty print as _fvar.123 instead of _uniq.123 (#3380)

Loose fvars are never supposed to be pretty printed, but having them
print with "fvar" in the name can help with debugging broken tactics and
elaborators.

Metaprogramming users often do not realize at first that `_uniq.???` in
pretty printing output refers to fvars not in the current local context.
This commit is contained in:
Kyle Miller 2024-02-17 17:53:37 -08:00 committed by GitHub
parent 433c4d22c2
commit d569ed4e5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 8 deletions

View file

@ -24,13 +24,13 @@ def unfoldMDatas : Expr → Expr
@[builtin_delab fvar]
def delabFVar : Delab := do
let Expr.fvar fvarId ← getExpr | unreachable!
try
let l ← fvarId.getDecl
maybeAddBlockImplicit (mkIdent l.userName)
catch _ =>
-- loose free variable, use internal name
maybeAddBlockImplicit <| mkIdent fvarId.name
let Expr.fvar fvarId ← getExpr | unreachable!
try
let l ← fvarId.getDecl
maybeAddBlockImplicit (mkIdent l.userName)
catch _ =>
-- loose free variable, use internal name
maybeAddBlockImplicit <| mkIdent (fvarId.name.replacePrefix `_uniq `_fvar)
-- loose bound variable, use pseudo syntax
@[builtin_delab bvar]

View file

@ -1,7 +1,7 @@
let y := Nat.zero;
Nat.add y y
fun y_1 => Nat.add y y_1
fun y => Nat.add _uniq.1 y
fun y => Nat.add _fvar.1 y
fun (y : Nat) => Nat.add y y
Nat.add ?m y
Nat.add (?m #0) #0