Skip to content

fix: include ignoreNoncomputable in LCNF cache key#13384

Merged
Kha merged 2 commits into
leanprover:masterfrom
Kha:push-pztpwwpqyorw
Apr 13, 2026
Merged

fix: include ignoreNoncomputable in LCNF cache key#13384
Kha merged 2 commits into
leanprover:masterfrom
Kha:push-pztpwwpqyorw

Conversation

@Kha
Copy link
Copy Markdown
Member

@Kha Kha commented Apr 13, 2026

This PR fixes a compiler panic when a structure constructor receives a noncomputable instance as an instance-implicit argument.

The LCNF translation first visits the instance in an irrelevant position (type parameter) where ignoreNoncomputable is true, caches the result, and then reuses that cached entry in a relevant position, bypassing checkComputable. Adding ignoreNoncomputable to the cache key ensures the two contexts do not share cache entries.

Fixes #13371

This PR fixes a compiler panic when a structure constructor receives a
noncomputable instance as an instance-implicit argument (leanprover#13371). The LCNF
translation first visits the instance in an irrelevant position (type
parameter) where `ignoreNoncomputable` is `true`, caches the result, and
then reuses that cached entry in a relevant position, bypassing
`checkComputable`. Adding `ignoreNoncomputable` to the cache key
ensures the two contexts do not share cache entries.
@Kha Kha requested review from hargoniX and leodemoura as code owners April 13, 2026 08:34
@hargoniX
Copy link
Copy Markdown
Contributor

!bench

@Kha Kha added the changelog-compiler Compiler, runtime, and FFI label Apr 13, 2026
@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 13, 2026

Benchmark results for fd64d7a against 41ab492 are in. There are no significant changes. @hargoniX

  • 🟥 build//instructions: +417.3M (+0.00%)

Small changes (1🟥)

  • 🟥 build/module/Lean.Compiler.LCNF.ToLCNF//instructions: +136.9M (+0.76%)

@leanprover-radar
Copy link
Copy Markdown

leanprover-radar commented Apr 13, 2026

Benchmark results for fd64d7a against 41ab492 are in. There are no significant changes. @Kha

  • 🟥 build//instructions: +417.3M (+0.00%)

Small changes (1🟥)

  • 🟥 build/module/Lean.Compiler.LCNF.ToLCNF//instructions: +136.9M (+0.76%)

This PR replaces the anonymous tuple cache key in LCNF translation with a
named `CacheKey` structure, making the role of each field (including
`ignoreNoncomputable`) explicit at construction sites.
@Kha Kha enabled auto-merge April 13, 2026 09:17
@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 Apr 13, 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-11 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-04-13 09:25:43)

mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 13, 2026
@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 Apr 13, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 13, 2026
@Kha Kha added this pull request to the merge queue Apr 13, 2026
Merged via the queue into leanprover:master with commit 0d7e76e Apr 13, 2026
17 checks passed
mathlib-nightly-testing Bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 13, 2026
mathlib-nightly-testing Bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 13, 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 Apr 13, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@Kha Kha deleted the push-pztpwwpqyorw branch April 14, 2026 12:55
volodeyka pushed a commit that referenced this pull request Apr 16, 2026
This PR fixes a compiler panic when a structure constructor receives a
noncomputable instance as an instance-implicit argument.

The LCNF translation first visits the instance in an irrelevant position
(type parameter) where `ignoreNoncomputable` is `true`, caches the
result, and then reuses that cached entry in a relevant position,
bypassing `checkComputable`. Adding `ignoreNoncomputable` to the cache
key ensures the two contexts do not share cache entries.

Fixes #13371
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 changelog-compiler Compiler, runtime, and FFI 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.

explicitBoxing panic when a constructor receives a noncomputable instance-implicit argument

4 participants