Skip to content

Commit

Permalink
Ignore use! and congrm. Add test file
Browse files Browse the repository at this point in the history
  • Loading branch information
adomani committed Apr 4, 2024
1 parent b348428 commit 5f02e63
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
10 changes: 4 additions & 6 deletions Mathlib/Tactic/TerminalRefineLinter.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ def refine? : Syntax → Bool
| .node _ ``Lean.Parser.Tactic.refine _ => true
| _ => false

/-- `refine? stx` detects whether the input syntax `stx` is `refine` or `refine'`. -/
def last : Syntax → Syntax
| .node _ ``Lean.Parser.Tactic.tacticSeq1Indented #[.node _ `null args] => args.back
| _ => .missing

/-- `SyntaxNodeKinds` that "contain" a `refine` and that the linter should ignore. -/
abbrev ignore : HashSet SyntaxNodeKind := HashSet.empty.insert `Mathlib.Tactic.useSyntax
abbrev ignore : HashSet SyntaxNodeKind := HashSet.empty
|>.insert `Mathlib.Tactic.useSyntax
|>.insert `Mathlib.Tactic.«tacticUse!___,,»
|>.insert `Mathlib.Tactic.congrM

/-- `refine_tree t` returns all terminal usages of `refine/refine'` in the input infotree. -/
partial
Expand Down
28 changes: 28 additions & 0 deletions test/TerminalRefineLinter.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Mathlib.Tactic.Use
import Mathlib.Tactic.Congrm
import Mathlib.Tactic.TerminalRefineLinter

#guard_msgs in
example : Nat := by
use 0

#guard_msgs in
example : Nat := by
use! 0

#guard_msgs in
example : 0 = 0 := by
congrm(_)

set_option linter.terminalRefine false in
set_option linter.terminalRefine true in
/--
warning: Please, use `exact` instead of `refine'`! [linter.terminalRefine]
---
warning: Please, use `exact` instead of `refine`! [linter.terminalRefine]
-/
#guard_msgs in
example : 0 = 00 = 0 := by
constructor
refine' rfl
refine rfl

0 comments on commit 5f02e63

Please sign in to comment.