This PR fixes `pp.fvars.anonymous` to display loose free variables as `_fvar._` instead of `_` when the option is set to `false`. This was the intended behavior in https://github.com/leanprover/lean4/pull/12688 but the fix was committed locally and not pushed before that PR was merged. 🤖 Prepared with Claude Code Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
27 lines
782 B
Text
27 lines
782 B
Text
import Lean
|
|
|
|
/-!
|
|
# Tests for `pp.fvars.anonymous`
|
|
|
|
When a free variable is not in the local context (a "loose" fvar),
|
|
the pretty printer renders it with an internal name like `_fvar.42`.
|
|
The `pp.fvars.anonymous` option (default `true`) controls this behavior:
|
|
when set to `false`, loose fvars are displayed as `_fvar._`.
|
|
-/
|
|
|
|
open Lean Elab Command in
|
|
#guard_msgs in
|
|
run_cmd liftTermElabM do
|
|
let fvarId : FVarId := { name := .num `_uniq 42 }
|
|
let e := Expr.fvar fvarId
|
|
let fmt ← Meta.ppExpr e
|
|
guard <| s!"{fmt}" == "_fvar.42"
|
|
|
|
set_option pp.fvars.anonymous false in
|
|
open Lean Elab Command in
|
|
#guard_msgs in
|
|
run_cmd liftTermElabM do
|
|
let fvarId : FVarId := { name := .num `_uniq 42 }
|
|
let e := Expr.fvar fvarId
|
|
let fmt ← Meta.ppExpr e
|
|
guard <| s!"{fmt}" == "_fvar._"
|