feat: introduce findMatchingDecl? for code quality checks in Lean.Linter - #14880
Merged
Conversation
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
wkrozowski
force-pushed
the
wkr/findPosition
branch
from
September 3, 2026 09:48
e8e23e4 to
d2d265d
Compare
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Sep 3, 2026
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Sep 3, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Sep 3, 2026
findMatchingDecl? for code quality checks wrapped in Lean.Linter (DRAFT)findMatchingDecl? for code quality checks in Lean.Linter
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Sep 3, 2026
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Sep 3, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Sep 3, 2026
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
Sep 3, 2026
mathlib-nightly-testing Bot
pushed a commit
to leanprover-community/mathlib4-nightly-testing
that referenced
this pull request
Sep 3, 2026
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Sep 3, 2026
wkrozowski
force-pushed
the
wkr/findPosition
branch
from
September 3, 2026 13:02
32343e5 to
c6b7249
Compare
leanprover-bot
added a commit
to leanprover/reference-manual
that referenced
this pull request
Sep 3, 2026
wkrozowski
marked this pull request as ready for review
September 3, 2026 13:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds
Lean.Linter.findMatchingDecl?, which finds the declaration a piece of syntax belongs to by searching the current command's info trees for declarations whose declaration range contains it, together withLean.Linter.findCodeQualitySource?andLean.Linter.findCodeQualitySource, which turn that declaration into a code-qualitySource(the latter falling back to the current module when no declaration matches). This gives linters a way to attribute diagnostics and code-quality entries to the declaration being elaborated.The helpers are exercised by a new package test,
tests/pkg/find_matching_decl, which registers a linter reporting the matched declaration and derived source for each command. It covers plain definitions, inductives, mutual blocks, classes, instances, and commands with no associated declaration.