feat: improve let error locality

This commit is contained in:
Sebastian Ullrich 2021-04-27 11:27:46 +02:00 committed by Leonardo de Moura
parent 9f0fa19237
commit 75e95f93a9
3 changed files with 14 additions and 3 deletions

View file

@ -546,13 +546,13 @@ def elabLetDeclAux (id : Syntax) (binders : Array Syntax) (typeStx : Syntax) (va
if useLetExpr then
withLetDecl id.getId type val fun x => do
addLocalVarInfo id x
let body ← elabTerm body expectedType?
let body ← elabTermEnsuringType body expectedType?
let body ← instantiateMVars body
mkLetFVars #[x] body
else
let f ← withLocalDecl id.getId BinderInfo.default type fun x => do
addLocalVarInfo id x
let body ← elabTerm body expectedType?
let body ← elabTermEnsuringType body expectedType?
let body ← instantiateMVars body
mkLambdaFVars #[x] body
pure <| mkApp f val

View file

@ -1,2 +1,7 @@
example : False :=
have False := _
example : 5 = 3 :=
have t : True := _
have f : 5 = 6 := _
f

View file

@ -1,4 +1,10 @@
have.lean:3:0: error: unexpected end of input
have.lean:4:0: error: expected term
have.lean:2:16-2:17: error: don't know how to synthesize placeholder
context:
⊢ False
have.lean:7:2-7:3: error: type mismatch
f
has type
5 = 6 : Prop
but is expected to have type
5 = 3 : Prop