Skip to content

fix: widen transparency field to 3 bits in Meta.Config cache key#13768

Merged
kim-em merged 2 commits into
leanprover:masterfrom
kim-em:fix-transparency-bitmask
May 18, 2026
Merged

fix: widen transparency field to 3 bits in Meta.Config cache key#13768
kim-em merged 2 commits into
leanprover:masterfrom
kim-em:fix-transparency-bitmask

Conversation

@kim-em
Copy link
Copy Markdown
Collaborator

@kim-em kim-em commented May 18, 2026

This PR fixes a long-standing bug in Meta.Config.toKey and Context.setTransparency where TransparencyMode was packed into only 2 bits of the cache key, even though it has 5 constructors (.all, .default, .reducible, .instances, .none). The .none case (value 4, i.e. 0b100) overlapped with the foApprox bit, so configurations differing only in transparency vs. foApprox could collide in the isDefEq/WHNF cache, and Context.setTransparency corrupted the neighbouring bit when switching to/from .none.

The fix widens the transparency field to 3 bits and shifts every subsequent flag up by one. Split out from #13637 where the same fix was needed anyway to accommodate a 6th transparency constructor.

🤖 Prepared with Claude Code

This PR fixes a bug in `Meta.Config.toKey` and `Context.setTransparency` where
`TransparencyMode` was packed into only 2 bits of the cache key, even though it
has 5 constructors (`.all`, `.default`, `.reducible`, `.instances`, `.none`).
The `.none` case (value `4`, i.e. `0b100`) overlapped with the `foApprox` bit,
which caused cache-key collisions between configurations differing only in
transparency vs. `foApprox`, and `Context.setTransparency` corrupted the
neighbouring bit when switching to/from `.none`. Widening the field to 3 bits
and shifting every subsequent flag up by one fixes both issues.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ne` transparency

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@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 18, 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-05-17 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-18 10:45:03)

@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 18, 2026
@kim-em kim-em enabled auto-merge May 18, 2026 10:47
@kim-em kim-em added this pull request to the merge queue May 18, 2026
Merged via the queue into leanprover:master with commit a68d753 May 18, 2026
17 checks passed
@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label May 18, 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

builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms 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