From 47d26badc82e606972a1b8a5285b78197411e067 Mon Sep 17 00:00:00 2001 From: Leni Aniva Date: Mon, 9 Dec 2024 17:30:33 -0800 Subject: [PATCH] feat: Capture mvar errors --- Pantograph/Goal.lean | 6 +++++- Test/Proofs.lean | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Pantograph/Goal.lean b/Pantograph/Goal.lean index e190d5d..4bb1afd 100644 --- a/Pantograph/Goal.lean +++ b/Pantograph/Goal.lean @@ -208,8 +208,12 @@ protected def GoalState.tryTacticM (state: GoalState) (goal: MVarId) (tacticM: E try 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. - 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 if m.severity == .error then return .some $ ← m.toString diff --git a/Test/Proofs.lean b/Test/Proofs.lean index 1903306..b48e3b0 100644 --- a/Test/Proofs.lean +++ b/Test/Proofs.lean @@ -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" 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 let state? ← startProof (.expr "∀ (p q r : Prop) (h : p → q), q ∧ r") 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 .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!":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) := let tests := [