Skip to content

Commit 0d5869b

Browse files
authored
fix: stuck "Missing alternative name" with incremental processing (#10848)
This PR fixes an issue where adding a missing case name after the pipe in `induction` would not remove the now-obsolete error message. Fixes #10847
1 parent 135e7e7 commit 0d5869b

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/Lean/Elab/Tactic/Induction.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ where
397397

398398
-- `checkAltNames` may have looked at arbitrary alternatives, so we need to disable incremental
399399
-- processing of alternatives if it had any effect lest we end up with stale messages
400+
let tacSnaps := if (← MonadLog.hasErrors) then #[] else tacSnaps
400401
Term.withoutTacticIncrementality (cond := (← MonadLog.hasErrors)) do
401402

402403
let mut alts := alts

tests/lean/interactive/incrementalCombinator.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,15 @@ example (n : Nat) : n = n := by
8787
| one => simp
8888
| succ => simp
8989
--^ collectDiagnostics
90+
91+
/-!
92+
"Missing alternative name" should not stick around.
93+
-/
94+
-- RESET
95+
example (n : Nat) : n = n := by
96+
induction n with
97+
| zero => simp
98+
| -- insert here
99+
--^ sync
100+
--^ insert: "succ => sorry"
101+
--^ collectDiagnostics

tests/lean/interactive/incrementalCombinator.lean.expected.out

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,13 @@ i 1.5
8787
"fullRange":
8888
{"start": {"line": 1, "character": 0},
8989
"end": {"line": 6, "character": 18}}}]}
90+
{"version": 2,
91+
"uri": "file:///incrementalCombinator.lean",
92+
"diagnostics":
93+
[{"source": "Lean 4",
94+
"severity": 2,
95+
"range":
96+
{"start": {"line": 1, "character": 0}, "end": {"line": 1, "character": 7}},
97+
"message": "declaration uses 'sorry'",
98+
"fullRange":
99+
{"start": {"line": 1, "character": 0}, "end": {"line": 1, "character": 7}}}]}

0 commit comments

Comments
 (0)