fix: withLocation should use withMainContext for target (#2607)

This commit is contained in:
Alex J Best 2023-10-04 01:12:43 +02:00 committed by GitHub
parent 6b93f05cd1
commit 44bc68bdc6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -49,7 +49,7 @@ def withLocation (loc : Location) (atLocal : FVarId → TacticM Unit) (atTarget
let fvarId ← getFVarId hyp
atLocal fvarId
if type then
atTarget
withMainContext atTarget
| Location.wildcard =>
let worked ← tryTactic <| withMainContext <| atTarget
withMainContext do

View file

@ -0,0 +1,15 @@
import Lean
open Lean Elab Tactic
elab "test" : tactic => do
withLocation (.targets #[] true) (fun _ => return ())
do
let some (_, lhs, _) := (← getMainTarget).eq? | failure
logInfo <| ← FVarId.getUserName (lhs.fvarId!)
(fun _ => return ())
example : 1 = 1 := by
let t := 1
show t = 1
test
sorry

View file

@ -0,0 +1,2 @@
t
withLocation.lean:11:0-11:7: warning: declaration uses 'sorry'