Skip to content

Commit

Permalink
Merge pull request #64 from Peiyang-Song/main
Browse files Browse the repository at this point in the history
Fix tactic suggestion formatting bug
  • Loading branch information
Peiyang-Song authored Apr 3, 2024
2 parents b983b89 + e4e672e commit d99af09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions LeanCopilot/Frontend.lean
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ def hint (stx : Syntax) (tacStrs : Array String) (check : Bool) : TacticM Unit :
if check then
let tacStxs ← tacStrs.filterMapM fun tstr : String => do match runParserCategory (← getEnv) `tactic tstr with
| Except.error _ => return none
| Except.ok stx => return some stx
| Except.ok stx => return some (tstr, stx)
let tacs := Nondet.ofList tacStxs.toList
let results := tacs.filterMapM fun t : Syntax => do
if let some msgs ← observing? (withMessageLog (withoutInfoTrees (evalTactic t))) then
return some (← getGoals, ← suggestion t.prettyPrint.pretty' msgs)
let results := tacs.filterMapM fun t : (String × Syntax) => do
if let some msgs ← observing? (withMessageLog (withoutInfoTrees (evalTactic t.2))) then
return some (← getGoals, ← suggestion t.1 msgs)
else
return none
let results ← (results.toMLList.takeUpToFirst fun r => r.1.1.isEmpty).asArray
Expand Down
2 changes: 2 additions & 0 deletions LeanCopilot/Tactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ elab_rules : tactic
if ← isVerbose then
logInfo s!"{elapsed.printAsMillis} for generating {tacticsWithScores.size} tactics"
let tactics := tacticsWithScores.map (·.1)
if ← isVerbose then
logInfo s!"Tactics: {tactics}"
let range : String.Range := { start := tac.getRange?.get!.start, stop := pfx.raw.getRange?.get!.stop }
let ref := Syntax.ofRange range
hint ref tactics (← SuggestTactics.checkTactics)
Expand Down

0 comments on commit d99af09

Please sign in to comment.