fix: synthesize pending mvars before trying coercions to Fun
`tests/lean/repr_issue.lean` cannot be elaborated with this modification.
This commit is contained in:
parent
2de7f1f4d9
commit
7b90f7d956
2 changed files with 14 additions and 3 deletions
|
|
@ -6,6 +6,7 @@ Authors: Leonardo de Moura
|
|||
import Lean.Util.FindMVar
|
||||
import Lean.Elab.Term
|
||||
import Lean.Elab.Binders
|
||||
import Lean.Elab.SyntheticMVars
|
||||
|
||||
namespace Lean
|
||||
namespace Elab
|
||||
|
|
@ -276,9 +277,18 @@ private partial def elabAppArgsAux : ElabAppArgsCtx → Expr → Expr → TermEl
|
|||
if ctx.namedArgs.isEmpty && ctx.argIdx == ctx.args.size then
|
||||
finalize ()
|
||||
else do
|
||||
e ← tryCoeFun eType e;
|
||||
eType ← inferType e;
|
||||
elabAppArgsAux ctx e eType
|
||||
-- eType may become a forallE after we synthesize pending metavariables
|
||||
synthesizeAppInstMVars ctx.instMVars;
|
||||
synthesizeSyntheticMVars;
|
||||
let ctx := { ctx with instMVars := #[] };
|
||||
-- try to normalize again.
|
||||
eType ← whnfForall eType;
|
||||
match eType with
|
||||
| Expr.forallE _ _ _ _ => elabAppArgsAux ctx e eType
|
||||
| _ => do
|
||||
e ← tryCoeFun eType e;
|
||||
eType ← inferType e;
|
||||
elabAppArgsAux ctx e eType
|
||||
|
||||
private def elabAppArgs (f : Expr) (namedArgs : Array NamedArg) (args : Array Arg)
|
||||
(expectedType? : Option Expr) (explicit : Bool) : TermElabM Expr := do
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
new_frontend
|
||||
def foo {m} [Monad m] [MonadExcept String m] [MonadState (Array Nat) m] : m Nat :=
|
||||
catch (do modify $ fun (a : Array Nat) => a.set! 0 33;
|
||||
throw "error")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue