fix: case tactic in macros (#4252)
We must erase macro scopes for tags in `case` as we do in `cases .. with ..` and `induction .. with ..`.
This commit is contained in:
parent
f97a7d4234
commit
2bc41d8f3a
2 changed files with 23 additions and 1 deletions
|
|
@ -469,7 +469,7 @@ def renameInaccessibles (mvarId : MVarId) (hs : TSyntaxArray ``binderIdent) : Ta
|
|||
private def getCaseGoals (tag : TSyntax ``binderIdent) : TacticM (MVarId × List MVarId) := do
|
||||
let gs ← getUnsolvedGoals
|
||||
let g ← if let `(binderIdent| $tag:ident) := tag then
|
||||
let tag := tag.getId
|
||||
let tag := tag.getId.eraseMacroScopes
|
||||
let some g ← findTag? gs tag | notFound gs tag
|
||||
pure g
|
||||
else
|
||||
|
|
|
|||
22
tests/lean/run/caseTacInMacros.lean
Normal file
22
tests/lean/run/caseTacInMacros.lean
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
def f (n : Nat) := n + 1
|
||||
|
||||
macro "mymacro1 " h:ident : tactic =>
|
||||
`(tactic| {
|
||||
cases $h:ident with
|
||||
| zero => decide
|
||||
| succ => simp_arith [f]
|
||||
})
|
||||
|
||||
example : f n > 0 := by
|
||||
mymacro1 n -- works
|
||||
|
||||
macro "mymacro2 " h:ident : tactic =>
|
||||
`(tactic| {
|
||||
cases $h:ident
|
||||
case zero => decide
|
||||
case succ => simp_arith [f]
|
||||
})
|
||||
|
||||
example : f n > 0 := by
|
||||
-- Should **not** generate: Case tag 'zero._@.cases3._hyg.747' not found.
|
||||
mymacro2 n
|
||||
Loading…
Add table
Reference in a new issue