fix: make sure inferProjType consume auxiliary type annotations

This commit is contained in:
Leonardo de Moura 2022-03-10 08:14:30 -08:00
parent 0ef8aaeda0
commit efc89eb4e1
3 changed files with 13 additions and 1 deletions

View file

@ -116,7 +116,7 @@ private def inferProjType (structName : Name) (idx : Nat) (e : Expr) : MetaM Exp
| _ => failed ()
ctorType ← whnf ctorType
match ctorType with
| Expr.forallE _ d _ _ => return d
| Expr.forallE _ d _ _ => return d.consumeTypeAnnotations
| _ => failed ()
def throwTypeExcepted {α} (type : Expr) : MetaM α :=

View file

@ -1,3 +1,4 @@
import Lean
structure A :=
x : Nat
a' : x = 1 := by trivial
@ -36,3 +37,13 @@ structure B :=
example (b : B) : b = { x := b.x, y := b.y } := by
cases b with
| mk x y => trace_state; rfl
open Lean
open Lean.Meta
def tst : MetaM Unit :=
withLocalDeclD `a (mkConst ``A) fun a => do
let e := mkProj ``A 1 a
IO.println (← Meta.ppExpr (← inferType e))
#eval tst

View file

@ -17,3 +17,4 @@ a' : x = 1
case mk
x y : Nat
⊢ { x := x, y := y } = { x := { x := x, y := y }.x, y := { x := x, y := y }.y }
a.1 = 1