Incorrect unused variable warning in lambda with pattern match and type signature #6264
Open
3 tasks done
Labels
bug
Something isn't working
Prerequisites
Please put an X between the brackets as you perform the following steps:
https://github.com/leanprover/lean4/issues
Avoid dependencies to Mathlib or Batteries.
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”)
Description
Incorrect "unused variable" warnings are reported around lambdas with pattern matches and explicit type annotations. See example below.
Context
Steps to Reproduce
Expected behavior: No unused variable warnings.
Actual behavior: Lean reports 3 unused variable warnings at the indicated locations:
p
at location 1 is unused, even though though 2 is its use.p
at location 2 anda
at location 3 are unused, even though these are not the variables' binding sites.Versions
4.13.0
Additional Information
The "2" warning goes away if we use
p
in the body of the lambda:as if Lean believes 2 is
p
's binding site which in turn shadows thep
bound at 1.The problem goes away if matching is moved out of the lambda:
The use of
(Subtype.mk _ _)
versus⟨_, _⟩
makes no difference.Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
The text was updated successfully, but these errors were encountered: