lean4-htt/tests/elab/12563.lean
Michael Rothgang fe3ba4dc4c
fix: make the omit, unusedSectionVars and loopingSimpArgs linter respect linter.all (#12563)
This PR makes the `omit`, `unusedSectionVars` and `loopingSimpArgs`
linters respect the `linter.all` option:
when `linter.all` is set to false (and the respective linter option is
unset), the linter should not report errors.

Similarly to #12559, these linters should honour the linter.all flag
being set to false. These are all remaining occurrences of this pattern.

This fixes an issue analogous to #12559.
This PR and #12560 fix all occurrences of this pattern. (The only
question is around `RCases.linter.unusedRCasesPattern`: should this also
respect this? I have left this alone for now.)

Co-authored-by: fiforeach <249703130+fiforeach@users.noreply.github.com>
2026-03-09 11:58:02 +00:00

195 lines
3.5 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-!
# Make the `unusedSectionVars`, `omit` and `loopingSimpArgs` linters honour the `linter.all` option
When e.g. `linter.unusedSectionVars` is not set explicitly, but the `linter.all` option is set,
the linter should behave accordingly; similarly for `linter.omit` and `linter.loopingSimpArgs`.
-/
/-! ## `linter.unusedSectionVars` -/
namespace UnusedSectionVars
section
set_option linter.unusedSectionVars true
variable {α : Type} [ToString α]
/--
warning: automatically included section variable(s) unused in theorem `UnusedSectionVars.myTheorem1`:
[ToString α]
consider restructuring your `variable` declarations so that the variables are not in scope or explicitly omit them:
omit [ToString α] in theorem ...
Note: This linter can be disabled with `set_option linter.unusedSectionVars false`
-/
#guard_msgs in
theorem myTheorem1 (a : α) : a = a := rfl
end
section
set_option linter.all true
variable {α : Type} [ToString α]
/--
warning: automatically included section variable(s) unused in theorem `UnusedSectionVars.myTheorem2`:
[ToString α]
consider restructuring your `variable` declarations so that the variables are not in scope or explicitly omit them:
omit [ToString α] in theorem ...
Note: This linter can be disabled with `set_option linter.unusedSectionVars false`
-/
#guard_msgs in
theorem myTheorem2 (a : α) : a = a := rfl
end
section
set_option linter.unusedSectionVars false
variable {α : Type} [ToString α]
theorem myTheorem3 (a : α) : a = a := rfl
end
section
set_option linter.all false
variable {α : Type} [ToString α]
theorem myTheorem4 (a : α) : a = a := rfl
end
end UnusedSectionVars
/-! ## `linter.omit` -/
namespace Omit
section
set_option linter.omit true
variable (α : Type)
/--
warning: `omit` should be avoided in favor of restructuring your `variable` declarations
Note: This linter can be disabled with `set_option linter.omit false`
-/
#guard_msgs in
omit α
end
section
set_option linter.all true
variable (α : Type)
/--
warning: `omit` should be avoided in favor of restructuring your `variable` declarations
Note: This linter can be disabled with `set_option linter.omit false`
-/
#guard_msgs in
omit α
end
section
set_option linter.omit false
variable (α : Type)
omit α
end
section
set_option linter.all false
variable (α : Type)
omit α
end
end Omit
/-! ## `linter.loopingSimpArgs` -/
namespace LoopingSimpArgs
set_option linter.unusedSimpArgs false -- can be removed after merging #12560
axiom testSorry : α
opaque a : Nat
theorem aa : a = id a := testSorry
section
set_option linter.loopingSimpArgs true
/--
warning: Possibly looping simp theorem: `aa`
Note: Possibly caused by: `id`
Hint: You can disable a simp theorem from the default simp set by passing `- theoremName` to `simp`.
Note: This linter can be disabled with `set_option linter.loopingSimpArgs false`
-/
#guard_msgs in
example : True := by simp -failIfUnchanged only [aa, id]
end
section
set_option linter.all true
/--
warning: Possibly looping simp theorem: `aa`
Note: Possibly caused by: `id`
Hint: You can disable a simp theorem from the default simp set by passing `- theoremName` to `simp`.
Note: This linter can be disabled with `set_option linter.loopingSimpArgs false`
-/
#guard_msgs in
example : True := by simp -failIfUnchanged only [aa, id]
end
section
set_option linter.loopingSimpArgs false
#guard_msgs in
example : True := by simp -failIfUnchanged only [aa, id]
end
section
set_option linter.all false
#guard_msgs in
example : True := by simp -failIfUnchanged only [aa, id]
end
end LoopingSimpArgs