Skip to content

Commit ab40faf

Browse files
committed
feat(Tactic/Recall): allow docstrings on recall (leanprover-community#37141)
This PR allows doc-strings to be placed before the `recall` command. The docstrings are parsed but ignored, since `recall` doesn't introduce a new declaration. This is useful when `recall` is used in expository files where surrounding declarations have docstrings. 🤖 Prepared with Claude Code
1 parent fb131a4 commit ab40faf

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Mathlib/Tactic/Recall.lean

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,19 @@ capture some details (like binders), so the following works without error.
3636
```
3737
recall Nat.add_comm {n m : Nat} : n + m = m + n
3838
```
39+
40+
Docstrings are permitted but are ignored:
41+
```
42+
/-- The additive commutativity of natural numbers. -/
43+
recall Nat.add_comm (n m : Nat) : n + m = m + n
44+
```
3945
-/
40-
syntax (name := recall) "recall " ident ppIndent(optDeclSig) (declVal)? : command
46+
syntax (name := recall) (docComment)? "recall " ident ppIndent(optDeclSig) (declVal)? : command
4147

4248
open Lean Meta Elab Command Term
4349

4450
elab_rules : command
45-
| `(recall $id $sig:optDeclSig $[$val?]?) => withoutModifyingEnv do
51+
| `($[$_doc?:docComment]? recall $id $sig:optDeclSig $[$val?]?) => withoutModifyingEnv do
4652
let declName := id.getId
4753
addConstInfo id declName
4854
let info ← getConstInfo declName

MathlibTest/Recall.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,6 @@ axiom bar : Nat
9393
#guard_msgs in recall bar := bar
9494

9595
recall List.cons_append (a : α) (as bs : List α) : (a :: as) ++ bs = a :: (as ++ bs) := rfl
96+
97+
/-- Recalling `Nat.add_comm`. -/
98+
recall Nat.add_comm (n m : Nat) : n + m = m + n

0 commit comments

Comments
 (0)