Compare commits

...

1 Commits

Author SHA1 Message Date
Leonardo de Moura
ed534b96db fix: case tactic in macros
We must erase macro scopes for tags in `case` as we do in `cases
.. with ..` and `induction .. with ..`.
2024-05-22 14:48:49 -07:00
2 changed files with 23 additions and 1 deletions

View File

@@ -392,7 +392,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

View 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