`linter.unusedVariables` false positive when used in `decreasing_by`
Open
Nobody has claimed this yet.
bug
P-medium
- Dominant language
- Lean
- Stars
- 9.2k
- Forks
- 990
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 175
Description
Prerequisites
- Put an X between the brackets on this line if you have done all of the following:
- Check that your issue is not already filed.
- Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to mathlib4 or std4.
Description
In some cases, the linter.unusedVariables yields false positives.
Context
Steps to Reproduce
variable (α : Type)
def sample (n : Nat) : Nat :=
match h : n with
| 0 => 0
| m + 1 => m + sample (m / 2)
decreasing_by
simp [h]
simp_wf
exact Nat.lt_of_le_of_lt (Nat.div_le_self _ _) (Nat.lt_succ_self _)
Expected behavior: No warning occurs.
Actual behavior: The message "unused variable h [linter.unusedVariables]" is shown.
Versions
Lean "4.3.0-rc2"
OS: lean playground's OS version
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 running the minimal sample reproducer with Lean and confirm that linter.unusedVariables reports h despite its use in decreasing_by. Trace the linter.unusedVariables implementation and its handling of termination proofs; done means the reproducer emits no unused-variable warning without regressing related linter behavior.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100