lean4-htt/tests/lean/run/439.lean
Kyle Miller d31066646d
feat: make #check and #reduce typecheck terms (#5079)
These commands were trusting that elaboration resulted in type-correct
terms, but users testing custom elaborators have found it to be
surprising that they do not do typechecking. This adds a `Meta.check`
step.
2024-08-31 02:39:38 +00:00

55 lines
948 B
Text

set_option pp.mvars false
universe u
structure Fn (E I : Sort u) := (exp : E) (imp : I)
instance (E I : Sort u) : CoeFun (Fn E I) (fun _ => I) := {coe := fun K => K.imp}
class Bar.{w} (P : Sort u) :=
fn : P -> Sort w
variable {P : Sort u} (B : Bar P)
variable (fn : Fn ((p : P) -> B.fn p) ({p : P} -> B.fn p))
#check (@fn : {p : P} → Bar.fn p) -- Result is as expected (implicit)
/-
fn.imp : {p : P} → Bar.fn p
-/
variable (p : P)
variable (Bp : Bar.fn p)
/--
error: function expected at
fn.imp
term has type
Bar.fn ?_
-/
#guard_msgs in
#check fn Bp
/--
error: function expected at
fn.imp
term has type
Bar.fn ?_
-/
#guard_msgs in
#check fn p
#check fn (p := p)
variable (fn' : Fn ((p : P) -> B.fn p -> B.fn p) ({p : P} -> B.fn p -> B.fn p))
#check fn' Bp
/--
error: application type mismatch
fn'.imp p
argument
p
has type
P : Sort u
but is expected to have type
Bar.fn ?_ : Sort _
-/
#guard_msgs in
#check fn' p