Skip to content

fix: prevent private default instances from leaking into public scope#13596

Open
Kha wants to merge 1 commit intoleanprover:masterfrom
Kha:push-ukrysnruvlwy
Open

fix: prevent private default instances from leaking into public scope#13596
Kha wants to merge 1 commit intoleanprover:masterfrom
Kha:push-ukrysnruvlwy

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented May 1, 2026

This PR fixes private(ly imported) default instances from accidentally being used in public signatures, leading to follow-up errors.

As reported at https://leanprover.zulipchat.com/#narrow/channel/270676-lean4/topic/Elaboration.20of.20heterogeneous.20mul.20with.20the.20module.20system

…oration

This PR fixes elaboration of expressions in public scope when a `@[default_instance]` is reachable only through a private `import`: such defaults are now skipped during default-instance synthesis instead of being tried and failing with `Unknown constant ...`, parallel to how regular instances are already filtered.

Implementation: `getDefaultInstances` now drops candidates whose constant is not publicly visible whenever `env.isExporting`, mirroring the filter in `Lean.Meta.SynthInstance.getInstances`. The `defaultInstanceExtension` also gains an `exportEntriesFnEx?` to drop entries with private names from the exported/server olean levels, parallel to the filter on `instanceExtension`.
@Kha Kha force-pushed the push-ukrysnruvlwy branch from 8fe14a4 to d803e1d Compare May 1, 2026 17:37
@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 May 1, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-04-29 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-05-01 18:30:32)

@github-actions github-actions Bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label May 1, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label May 1, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

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

Labels

breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

2 participants