Skip to content

Conversation

@kim-em
Copy link
Collaborator

@kim-em kim-em commented Jan 4, 2026

This PR fixes a panic that occurred when a theorem had a docstring on an
auxiliary definition within a where clause.

Reproducer:

theorem foo : True := aux where /-- -/ aux := True.intro

The issue was that asyncMayModify used .any to check if a nested
declaration could have its extension state modified, which returned
false when the declaration wasn't yet in asyncConsts. Using .all
instead returns true for none (vacuously true), allowing modification
of extension state for nested declarations that haven't been added to
asyncConsts yet.

Closes #11799

🤖 Prepared with Claude Code

… `where`

This PR fixes a panic that occurred when a theorem had a docstring on an
auxiliary definition within a `where` clause.

The issue was that `asyncMayModify` used `.any` to check if a nested
declaration could have its extension state modified, which returned
`false` when the declaration wasn't yet in `asyncConsts`. Using `.all`
instead returns `true` for `none` (vacuously true), allowing modification
of extension state for nested declarations that haven't been added to
`asyncConsts` yet.

Closes #11799

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@kim-em kim-em added the changelog-language Language features and metaprograms label Jan 4, 2026
@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 Jan 5, 2026
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 9f404d8fbe334425cc6fd1e44b01d00f59f695ed --onto 4e8b5cfc4696efb13c2fb3dc8ae6033197ae2b1f. You can force Mathlib CI using the force-mathlib-ci label. (2026-01-05 00:45:59)

@leanprover-bot
Copy link
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 9f404d8fbe334425cc6fd1e44b01d00f59f695ed --onto 78c9a01bb265cdddb5d187a02ba2200479b3f97c. You can force reference manual CI using the force-manual-ci label. (2026-01-05 00:46:01)

/-- first aux -/ aux1 := True.intro
/-- second aux -/ aux2 := True.intro

-- Verify the docstrings are actually attached
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be testing the doc-strings, but rather that the functions themselves exist, right?

Use `findDocString?` to verify the docstrings are correctly set,
rather than just checking the declarations exist.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@kim-em kim-em force-pushed the fix-docstring-panic-where-clause branch from 9f81281 to c24b063 Compare January 10, 2026 09:23
Use `.trimAscii` to ignore leading/trailing whitespace when comparing
docstrings, since `/-- doc -/` includes the trailing space.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@kim-em kim-em force-pushed the fix-docstring-panic-where-clause branch from c24b063 to 37acc90 Compare January 10, 2026 09:24
@kim-em kim-em enabled auto-merge January 10, 2026 09:25
@kim-em kim-em added this pull request to the merge queue Jan 10, 2026
Merged via the queue into master with commit 9280a0b Jan 10, 2026
15 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Jan 11, 2026
…h docstrings in `where`" (#11969)

Reverts #11896 as it is not a principled fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms 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.

panic in async elaboration for theorems with a docstring within where

5 participants