linter.unusedSectionVars: does not detect variable uses in where clauses
Nobody has claimed this yet.
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
The unused section variable linter does not detect when a variable is used inside a where clause.
MWE
variable (n : Nat)
include n
theorem foo : ∃ (_ : Nat), True := by
exists k
where
k := n + 1
This produces a warning:
automatically included section variable(s) unused in theorem 'foo':
n
consider restructuring your `variable` declarations so that the variables are not in scope or explicitly omit them:
omit n in theorem ...
note: this linter can be disabled with `set_option linter.unusedSectionVars false`
But n is used in the where clause (k := n + 1).
Discussion
Note: the same Zulip thread also reports a related issue where the linter warns about an instance that cannot be omitted because it's referenced in the type of another included variable.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the MWE and tracing the unusedSectionVars linter entry point. Check why references from where clauses are missed, then verify that the example no longer reports n as unused. The linked Zulip discussion also notes a related instance-omission case that may need separate consideration.
Written by the indexing model from the issue text.
Assessment
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100