fix: catch mkAppM exceptions
This commit is contained in:
parent
96de208a6b
commit
fdbe893c40
2 changed files with 18 additions and 1 deletions
|
|
@ -103,9 +103,9 @@ private def throwForInFailure (forInInstance : Expr) : TermElabM Expr :=
|
|||
let m ← getMonadForIn expectedType?
|
||||
let colType ← inferType colFVar
|
||||
let elemType ← mkFreshExprMVar (mkSort (mkLevelSucc (← mkFreshLevelMVar)))
|
||||
let memType ← mkFreshExprMVar (← mkAppM ``Membership #[elemType, colType])
|
||||
let forInInstance ←
|
||||
try
|
||||
let memType ← mkFreshExprMVar (← mkAppM ``Membership #[elemType, colType])
|
||||
mkAppM ``ForIn' #[m, colType, elemType, memType]
|
||||
catch
|
||||
ex => tryPostpone; throwError "failed to construct `ForIn'` instance for collection{indentExpr colType}\nand monad{indentExpr m}"
|
||||
|
|
|
|||
17
tests/lean/run/forInElabBug.lean
Normal file
17
tests/lean/run/forInElabBug.lean
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Std
|
||||
|
||||
namespace Std.BinomialHeapImp
|
||||
|
||||
open Heap
|
||||
|
||||
partial def toArrayUnordered' (h : Heap α) : Array α :=
|
||||
go #[] h
|
||||
where
|
||||
go (acc : Array α) : Heap α → Array α
|
||||
| heap ns => Id.run do
|
||||
let mut acc := acc
|
||||
for h₁ : n in ns do
|
||||
acc := acc.push n.val
|
||||
for h₂ : h in n.children do
|
||||
acc := go acc h
|
||||
return acc
|
||||
Loading…
Add table
Reference in a new issue