Skip to content

feat: add pp.fvars.anonymous option#12688

Merged
kim-em merged 1 commit intoleanprover:masterfrom
kim-em:kim/pp-fvars-anonymous
Mar 1, 2026
Merged

feat: add pp.fvars.anonymous option#12688
kim-em merged 1 commit intoleanprover:masterfrom
kim-em:kim/pp-fvars-anonymous

Conversation

@kim-em
Copy link
Collaborator

@kim-em kim-em commented Feb 25, 2026

This PR adds a pp.fvars.anonymous option (default true) that controls the display of loose free variables (fvars not in the local context).

  • When true (default), loose fvars display their internal name like _fvar.42
  • When false, they display as _fvar._

This is analogous to pp.mvars.anonymous for metavariables. It's useful for stabilizing output in #guard_msgs when messages contain fvar IDs that vary between runs — for example, in diagnostic tools that report isDefEq failures from trace output where the local context is not available.

🤖 Prepared with Claude Code

Add a `pp.fvars.anonymous` option (default `true`) that controls the
display of loose free variables (fvars not in the local context).

When `true` (default), loose fvars are displayed with their internal
name like `_fvar.42`. When `false`, they are displayed as `_`.

This is analogous to `pp.mvars.anonymous` for metavariables, and is
useful for stabilizing output in `#guard_msgs` when messages contain
fvar IDs that vary between runs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kim-em kim-em requested a review from kmill as a code owner February 25, 2026 11:36
@github-actions github-actions bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Feb 25, 2026
@mathlib-lean-pr-testing
Copy link

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase e96d969d5935c1b026c0e80d60626c8da88d0922 --onto c595413fccaa47ebdc399d9b817c17425687fc26. You can force Mathlib CI using the force-mathlib-ci label. (2026-02-25 12:34:27)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase e96d969d5935c1b026c0e80d60626c8da88d0922 --onto 8038a8b8904f89ad9542c8eda11379f8f006eab1. You can force reference manual CI using the force-manual-ci label. (2026-02-25 12:34:29)

@kim-em kim-em added the changelog-pp Pretty printing label Feb 27, 2026
@kim-em kim-em added this pull request to the merge queue Mar 1, 2026
Merged via the queue into leanprover:master with commit 5dd8d57 Mar 1, 2026
30 of 31 checks passed
github-actions bot pushed a commit that referenced this pull request Mar 1, 2026
This PR adds a `pp.fvars.anonymous` option (default `true`) that
controls the display of loose free variables (fvars not in the local
context).

- When `true` (default), loose fvars display their internal name like
`_fvar.42`
- When `false`, they display as `_fvar._`

This is analogous to `pp.mvars.anonymous` for metavariables. It's useful
for stabilizing output in `#guard_msgs` when messages contain fvar IDs
that vary between runs — for example, in diagnostic tools that report
`isDefEq` failures from trace output where the local context is not
available.

🤖 Prepared with Claude Code

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit 5dd8d57)
github-merge-queue bot pushed a commit that referenced this pull request Mar 1, 2026
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 #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>
kim-em added a commit that referenced this pull request Mar 1, 2026
Backport 5dd8d57 from #12688.

Co-authored-by: Kim Morrison <477956+kim-em@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
kim-em added a commit that referenced this pull request Mar 1, 2026
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 #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>
Copy link
Collaborator

@kmill kmill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed my review from a few days ago didn't get posted.

It looks like you went with _fvar._ in #12745, which is at least as reasonable as my suggestion.

-- use internal name like `_fvar.22`
maybeAddBlockImplicit <| mkIdent (fvarId.name.replacePrefix `_uniq `_fvar)
else
maybeAddBlockImplicit <| mkIdent `_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using something that communicates that this is an fvar?

Suggested change
maybeAddBlockImplicit <| mkIdent `_
maybeAddBlockImplicit <| mkIdent `_fvar

With pp.mvars.anonymous, you can tell that what's being pretty printed is a metavariable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport releases/v4.29.0 changelog-pp Pretty printing toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants