Skip to content

Commit 3d55951

Browse files
committed
feat: just warning if script cannot be replayed
1 parent 1643fd7 commit 3d55951

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Lean/Elab/Tactic/Grind/Trace.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def withTracing (x : GrindTacticM α) : GrindTacticM α := do
2020

2121
def mkFinish (maxIterations : Nat) : IO Action := do
2222
let solvers ← Solvers.mkAction
23-
return Action.checkTactic >> (Action.done <|> solvers <|> Action.instantiate <|> Action.splitNext).loop maxIterations
23+
let step : Action := Action.done <|> solvers <|> Action.instantiate <|> Action.splitNext <|> Action.mbtc
24+
return Action.checkTactic (warnOnly := true) >> step.loop maxIterations
2425

2526
def maxIterations := 1000 -- **TODO**: Add option
2627

src/Lean/Meta/Tactic/Grind/Action.lean

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,26 @@ def checkSeqAt (s? : Option SavedState) (goal : Goal) (seq : List TGrind) : Grin
282282
/--
283283
Helper action that checks whether the resulting tactic script produced by its continuation
284284
can close the original goal.
285+
If `warnOnly = true`, just generates a warning message instead of an error
285286
-/
286-
def checkTactic : Action := fun goal _ kp => do
287+
def checkTactic (warnOnly : Bool) : Action := fun goal _ kp => do
287288
let s ← saveStateIfTracing
288289
let r ← kp goal
289290
match r with
290291
| .closed seq =>
291292
unless (← checkSeqAt s goal seq) do
292-
throwError "generated tactic cannot close the goal{indentD (← mkGrindNext seq)}\nInitial goal\n{goal.mvarId}"
293+
let m := m!"generated tactic cannot close the goal{indentD (← mkGrindNext seq)}\nInitial goal\n{goal.mvarId}"
294+
if warnOnly then
295+
logWarning m
296+
else
297+
throwError m
293298
return r
294299
| _ => return r
295300

296301
/--
297302
Helper action for satellite solvers that use `CheckResult`.
298303
-/
299-
def solverAction (check : GoalM CheckResult) (mkTac : GrindM (TSyntax `grind)) : Action := fun goal kna kp => do
304+
def solverAction (check : GoalM CheckResult) (mkTac : GrindM TGrind) : Action := fun goal kna kp => do
300305
let saved? ← saveStateIfTracing
301306
let (result, goal') ← GoalM.run goal check
302307
match result with

0 commit comments

Comments
 (0)