feat: Capture mvar errors

This commit is contained in:
Leni Aniva 2024-12-09 17:30:33 -08:00
parent 7fc2bd0d0f
commit 47d26badc8
Signed by: aniva
GPG Key ID: 4D9B1C8D10EA4C50
2 changed files with 8 additions and 2 deletions

View File

@ -208,8 +208,12 @@ protected def GoalState.tryTacticM (state: GoalState) (goal: MVarId) (tacticM: E
try try
let nextState ← state.step goal tacticM let nextState ← state.step goal tacticM
Elab.Term.synthesizeSyntheticMVarsNoPostponing
let descendants ← Meta.getMVars $ ← instantiateMVars (.mvar goal)
let _ ← Elab.Term.logUnassignedUsingErrorInfos descendants
-- Check if error messages have been generated in the core. -- Check if error messages have been generated in the core.
let newMessages ← (← Core.getMessageLog).toList.drop state.coreState.messages.toList.length let newMessages ← (← Core.getMessageLog).toList --.drop state.coreState.messages.toList.length
|>.filterMapM λ m => do |>.filterMapM λ m => do
if m.severity == .error then if m.severity == .error then
return .some $ ← m.toString return .some $ ← m.toString

View File

@ -720,6 +720,7 @@ def test_tactic_failure_unresolved_goals : TestM Unit := do
let .failure messages ← state1.tacticOn 0 tactic | addTest $ assertUnreachable s!"{tactic} should fail" let .failure messages ← state1.tacticOn 0 tactic | addTest $ assertUnreachable s!"{tactic} should fail"
checkEq s!"{tactic} fails" messages #[s!"{← getFileName}:0:12: error: unsolved goals\np : Nat → Prop\n⊢ p 0\n"] checkEq s!"{tactic} fails" messages #[s!"{← getFileName}:0:12: error: unsolved goals\np : Nat → Prop\n⊢ p 0\n"]
def test_tactic_failure_synthesize_placeholder : TestM Unit := do def test_tactic_failure_synthesize_placeholder : TestM Unit := do
let state? ← startProof (.expr "∀ (p q r : Prop) (h : p → q), q ∧ r") let state? ← startProof (.expr "∀ (p q r : Prop) (h : p → q), q ∧ r")
let state0 ← match state? with let state0 ← match state? with
@ -737,7 +738,8 @@ def test_tactic_failure_synthesize_placeholder : TestM Unit := do
let tactic := "simpa [h] using And.imp_left h _" let tactic := "simpa [h] using And.imp_left h _"
let .failure messages ← state1.tacticOn 0 tactic | addTest $ assertUnreachable s!"{tactic} should fail" let .failure messages ← state1.tacticOn 0 tactic | addTest $ assertUnreachable s!"{tactic} should fail"
checkEq s!"{tactic} fails" messages #[s!"{← getFileName}:0:12: error: unsolved goals\np : Nat → Prop\n⊢ p 0\n"] let message := s!"<Pantograph>:0:31: error: don't know how to synthesize placeholder\ncontext:\np q r : Prop\nh : p → q\n⊢ p ∧ r\n"
checkEq s!"{tactic} fails" messages #[message]
def suite (env: Environment): List (String × IO LSpec.TestSeq) := def suite (env: Environment): List (String × IO LSpec.TestSeq) :=
let tests := [ let tests := [