fix: pretty printing loose bvars

Fixes #192
This commit is contained in:
Sebastian Ullrich 2020-09-23 11:13:23 +02:00
parent d66b6738ee
commit fa55c1e088
4 changed files with 16 additions and 2 deletions

View file

@ -261,7 +261,7 @@ catch
@[builtinDelab bvar]
def delabBVar : Delab := do
Expr.bvar idx _ ← getExpr | unreachable!;
pure $ mkIdent $ "#" ++ toString idx
pure $ mkIdent $ mkNameSimple $ "#" ++ toString idx
@[builtinDelab mvar]
def delabMVar : Delab := do

View file

@ -289,7 +289,9 @@ let id := id.simpMacroScopes;
let s := id.toString;
if id.isAnonymous then
pushToken "[anonymous]"
else if LocalContext.isInaccessibleUserName id || id.components.any Name.isNum then
else if LocalContext.isInaccessibleUserName id || id.components.any Name.isNum ||
-- loose bvar
"#".isPrefixOf s then
-- not parsable anyway, output as-is
pushToken s
else do {

11
tests/lean/ppExpr.lean Normal file
View file

@ -0,0 +1,11 @@
import Lean
new_frontend
/-! Pretty printing tests for `Expr`s that cannot be generated by parsing+elaborating. -/
open Lean
def test (e : Expr) : MetaM Unit :=
PrettyPrinter.ppExpr Name.anonymous [] e >>= IO.println
#eval test (mkBVar 0)

View file

@ -0,0 +1 @@
#0