fix: make sure "dependent elimination failed" error is on cases (#9551)

This PR fixes the error position for the "dependent elimination failed"
error for the `cases` tactic.
This commit is contained in:
Kyle Miller 2025-07-25 12:02:42 -07:00 committed by GitHub
parent 7f39e56a79
commit 98569c7cf0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 20 additions and 1 deletions

View file

@ -372,7 +372,7 @@ where
goWithIncremental #[]
-- continuation in the correct incrementality context
goWithIncremental (tacSnaps : Array (SnapshotBundle TacticParsedSnapshot)) := do
goWithIncremental (tacSnaps : Array (SnapshotBundle TacticParsedSnapshot)) := withRef tacStx do
let hasAlts := altStxs?.isSome
let altStxs := altStxs?.getD #[]
let mut alts := alts

View file

@ -70,3 +70,11 @@ theorem cases (n : Nat) : True := by
dbg_trace "c 2"
--^ sync
--^ insert: ".5"
-- RESET
/-!
Regression test: make sure the dependent elimination error appears on `cases`
-/
example (f : Nat → Nat) (n : Nat) (h : f n = n) := by
cases h
--^ collectDiagnostics

View file

@ -37,3 +37,14 @@ c 2
c 1.5
c 2
c 2.5
{"version": 1,
"uri": "file:///incrementalInduction.lean",
"diagnostics":
[{"source": "Lean 4",
"severity": 1,
"range":
{"start": {"line": 5, "character": 2}, "end": {"line": 5, "character": 7}},
"message":
"dependent elimination failed, failed to solve equation\n n = f n",
"fullRange":
{"start": {"line": 5, "character": 2}, "end": {"line": 5, "character": 7}}}]}