Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make MapDeclarationExtension tolerate multiple insertions #5911

Merged
merged 2 commits into from
Nov 2, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Nov 1, 2024

Simplifies the definition of MapDeclarationExtension so that it only contains a NameMap without an additional List (Name × α). Uses the NameMap's natural ordering during export rather than sorting.

This fixes issues from inserting into a MapDeclarationExtension multiple times with the same key. Inside a module it appears that each insertion overwrites the data, since those queries access the NameMap. But across modules, only the first insertion is accessible, since each insertion was actually pushed to the front of a List.

Mathlib needs this for a documentation extension feature, and they are considering a PR with a workaround that digs into the MapDeclarationExtension data structures.

Simplifies the definition of `MapDeclarationExtension` so that it only contains a `NameMap` without an additional `List (Name × α)`. Uses the `NameMap`'s natural ordering during export rather than sorting.

This fixes issues from inserting into a `MapDeclarationExtension` multiple times with the same key. Inside a module it appears that each insertion overwrites the data, since those queries access the `NameMap`. But across modules, only the first insertion is accessible, since each insertion was actually pushed to the front of a `List`.

Mathlib needs this for a documentation extension feature, and [they are considering a PR with a workaround](leanprover-community/mathlib4#17043) that digs into the `MapDeclarationExtension` data structures.
@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 Nov 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 1, 2024
@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Nov 1, 2024
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Nov 1, 2024

Mathlib CI status (docs):

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Nov 1, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Nov 1, 2024
@kmill kmill added this pull request to the merge queue Nov 2, 2024
Merged via the queue into leanprover:master with commit 3c15ab3 Nov 2, 2024
14 checks passed
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 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