fix: add checkSystem and withIncRecDepth to withAutoBoundImplicit (#4128)
Fix stack overflow crash. Closes #4117 The fix can be improved: we could try to avoid creating hundreds of auto implicits before failing.
This commit is contained in:
parent
6c6b56e7fc
commit
a6d186a81d
4 changed files with 6 additions and 3 deletions
|
|
@ -1523,7 +1523,8 @@ partial def withAutoBoundImplicit (k : TermElabM α) : TermElabM α := do
|
|||
let flag := autoImplicit.get (← getOptions)
|
||||
if flag then
|
||||
withReader (fun ctx => { ctx with autoBoundImplicit := flag, autoBoundImplicits := {} }) do
|
||||
let rec loop (s : SavedState) : TermElabM α := do
|
||||
let rec loop (s : SavedState) : TermElabM α := withIncRecDepth do
|
||||
checkSystem "auto-implicit"
|
||||
try
|
||||
k
|
||||
catch
|
||||
|
|
|
|||
1
tests/lean/4117.lean
Normal file
1
tests/lean/4117.lean
Normal file
|
|
@ -0,0 +1 @@
|
|||
structure D:=(t:A)(c N:={s with} 0
|
||||
1
tests/lean/4117.lean.expected.out
Normal file
1
tests/lean/4117.lean.expected.out
Normal file
|
|
@ -0,0 +1 @@
|
|||
4117.lean:2:0: error: unexpected end of input; expected ')'
|
||||
|
|
@ -35,8 +35,8 @@ info: [simp] used theorems (max: 1201, num: 3):
|
|||
⏎
|
||||
Nat.reduceAdd (builtin simproc) ↦ 771
|
||||
⏎
|
||||
ack.eq_1 ↦ 768[simp] tried theorems (max: 1974, num: 2):
|
||||
ack.eq_3 ↦ 1974, succeeded: 1201
|
||||
ack.eq_1 ↦ 768[simp] tried theorems (max: 1973, num: 2):
|
||||
ack.eq_3 ↦ 1973, succeeded: 1201
|
||||
⏎
|
||||
ack.eq_1 ↦ 768, succeeded: 768use `set_option diagnostics.threshold <num>` to control threshold for reporting counters
|
||||
---
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue