fix: pretty printing of constants should consider accessibility of names#12654
Merged
kmill merged 5 commits intoleanprover:masterfrom Feb 25, 2026
Merged
fix: pretty printing of constants should consider accessibility of names#12654kmill merged 5 commits intoleanprover:masterfrom
kmill merged 5 commits intoleanprover:masterfrom
Conversation
This PR fixes pretty printing of private names. The name unresolution algorithm now works by finding a valid fully qualified name, if one exists, and then finds an efficient name from that. Inaccessible private names do not have a fully qualified name for this purpose. Secondly, the delaborator for constants now deterministically adds macro scopes to inaccessible names. There is a small hack to support the compiler's pretty printing. It prints constants that do not exist (e.g. `obj`, `tobj`, and auxiliary definitions being compiled). These still have some accessibility analysis (private names for the current module have the private prefix stripped), and they are otherwise pretty printed as-is without additional macro scopes. Closes leanprover#10771
Collaborator
|
Reference manual CI status:
|
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Feb 23, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Feb 23, 2026
|
Mathlib CI status (docs):
|
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Feb 24, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Feb 24, 2026
|
Mathlib CI status (docs):
|
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Feb 24, 2026
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Feb 24, 2026
|
Mathlib CI status (docs):
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes two aspects of pretty printing of private names.
_root_prefix is added, then it tries resolving all suffixes of the result. This is sufficient to handle imported private names in the new module system. (Additionally, unresolution takes macro scopes into account now.)✝suffix each time. It used to use fresh macro scopes per occurrence.Note: There is currently a small hack to support pretty printing in the compiler's trace messages, which print constants that do not exist (e.g.
obj,tobj, and auxiliary definitions being compiled). Even though these names are inaccessible (for the stronger reason that they don't exist), we make sure that the pretty printer won't add macro scopes. It also does some analysis of private names to see if the private names are for the current module.Closes #10771, closes #10772, and closes #10773