Skip to content

Commit 351a941

Browse files
kim-emclaude
andauthored
fix: show deprecation warnings for grind theorem arguments (#11593)
This PR fixes an issue where `grind` did not display deprecation warnings when deprecated lemmas were used in its argument list. The fix adds explicit calls to `Linter.checkDeprecated` after resolving theorem names in both `processParam` (for theorem arguments) and `elabGrindParams` (for the `-` erase syntax). Closes #11582 🤖 Prepared with Claude Code Co-authored-by: Claude Opus 4.5 <[email protected]>
1 parent 124e34e commit 351a941

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Lean/Elab/Tactic/Grind/Param.lean

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def processParam (params : Grind.Params)
9696
throwErrorAt id "redundant parameter `{id}`, `grind` uses local hypotheses automatically"
9797
else
9898
throw err
99+
Linter.checkDeprecated declName
99100
let kind ← if let some mod := mod? then Grind.getAttrKindCore mod else pure .infer
100101
match kind with
101102
| .ematch .user =>
@@ -221,6 +222,7 @@ public def elabGrindParams (params : Grind.Params) (ps : TSyntaxArray ``Parser.T
221222
if incremental then
222223
throwErrorAt p "invalid `-` occurrence, it can only used at the `grind` tactic entry point"
223224
let declName ← realizeGlobalConstNoOverloadWithInfo id
225+
Linter.checkDeprecated declName
224226
if let some declName ← Grind.isCasesAttrCandidate? declName false then
225227
Grind.ensureNotBuiltinCases declName
226228
params := { params with casesTypes := (← params.casesTypes.eraseDecl declName) }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/-!
2+
Test that `grind` flags deprecated theorems.
3+
See https://github.com/leanprover/lean4/issues/11582
4+
-/
5+
set_option backward.grind.inferPattern true -- Use old pattern inference (no suggestions)
6+
set_option linter.deprecated true -- Enable the deprecated linter (test framework disables all linters)
7+
8+
def foo : Nat := 0
9+
10+
@[deprecated "use foo_eq_zero' instead" (since := "2025-01-01")]
11+
theorem foo_eq_zero : foo = 0 := rfl
12+
13+
/-- warning: `foo_eq_zero` has been deprecated: use foo_eq_zero' instead -/
14+
#guard_msgs in
15+
example : foo = foo := by grind [foo_eq_zero]
16+
17+
-- Also test the `-` syntax for erasing theorems
18+
@[grind]
19+
theorem bar_eq_zero : foo = 0 := rfl
20+
21+
-- This theorem is deprecated AND marked with @[grind], so we can erase it
22+
@[deprecated bar_eq_zero (since := "2025-01-01"), grind]
23+
theorem bar_eq_zero' : foo = 0 := rfl
24+
25+
/-- warning: `bar_eq_zero'` has been deprecated: Use `bar_eq_zero` instead -/
26+
#guard_msgs in
27+
example : foo = foo := by grind [- bar_eq_zero']

0 commit comments

Comments
 (0)