Skip to content

fix: when pretty printing constant names, do not use aliases from "non-API exports"#5689

Merged
kmill merged 3 commits intoleanprover:masterfrom
kmill:pp_name_non-api
Dec 10, 2024
Merged

fix: when pretty printing constant names, do not use aliases from "non-API exports"#5689
kmill merged 3 commits intoleanprover:masterfrom
kmill:pp_name_non-api

Conversation

@kmill
Copy link
Copy Markdown
Collaborator

@kmill kmill commented Oct 13, 2024

This PR adjusts the way the pretty printer unresolves names. It used to make use of all exports when pretty printing, but now it only uses exports that put names into parent namespaces (heuristic: these are "API exports" that are intended by the library author), rather than "horizontal exports" that put the names into an unrelated namespace, which the dot notation feature in #6189 now incentivizes.

Closes the already closed #2524

@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 Oct 13, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Oct 13, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Oct 13, 2024
@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label Oct 13, 2024
@ghost
Copy link
Copy Markdown

ghost commented Oct 13, 2024

Mathlib CI status (docs):

  • ✅ Mathlib branch lean-pr-testing-5689 has successfully built against this PR. (2024-10-13 18:56:13) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase ca96922b4be5d395f6e3102ed3c8950e18982be7 --onto 86f303774a7fbf38406ae13bd4b66f2753643a45. (2024-11-30 23:08:05)
  • ✅ Mathlib branch lean-pr-testing-5689 has successfully built against this PR. (2024-12-10 18:37:46) View Log

@kmill
Copy link
Copy Markdown
Collaborator Author

kmill commented Oct 20, 2024

#5689 was chosen in favor of this for closing #2524. I'll keep this open for now, but if the triage team wants to close it, go ahead.

@kmill kmill added the changelog-pp Pretty printing label Nov 30, 2024
…n-API" `export`s

Heuristic: an "API" `export` is one that exports a declaration to a parent namespace. This PR makes it so that aliases created by `export` from exporting a name into some parallel namespace are not considered.

This is motivated by Lake's use of `export` to make some declarations like `Lean.Name` permanently available in the `Lake` namespace. A consequence to this is that in docgen, we see `Lean.Name` pretty printed as `Lake.Name`.

Another solution would be to create a `scoped open` command that auto-opens some names whenever a namespace is activated. If that is ever implemented, it would be easy to revert the changes in this PR.

Closes leanprover#2524
@kmill kmill enabled auto-merge December 10, 2024 17:26
@kmill kmill added this pull request to the merge queue Dec 10, 2024
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Dec 10, 2024
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Dec 10, 2024
Merged via the queue into leanprover:master with commit cd909b0 Dec 10, 2024
luisacicolini pushed a commit to opencompl/lean4 that referenced this pull request Jan 21, 2025
…n-API `export`s" (leanprover#5689)

This PR adjusts the way the pretty printer unresolves names. It used to
make use of all `export`s when pretty printing, but now it only uses
`export`s that put names into parent namespaces (heuristic: these are
"API exports" that are intended by the library author), rather than
"horizontal exports" that put the names into an unrelated namespace,
which the dot notation feature in leanprover#6189 now incentivizes.

Closes the already closed leanprover#2524
JovanGerb pushed a commit to JovanGerb/lean4 that referenced this pull request Jan 21, 2025
…n-API `export`s" (leanprover#5689)

This PR adjusts the way the pretty printer unresolves names. It used to
make use of all `export`s when pretty printing, but now it only uses
`export`s that put names into parent namespaces (heuristic: these are
"API exports" that are intended by the library author), rather than
"horizontal exports" that put the names into an unrelated namespace,
which the dot notation feature in leanprover#6189 now incentivizes.

Closes the already closed leanprover#2524
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR 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.

Delaboration of re-exported names

1 participant