This PR improves the “expected type mismatch” error message by omitting the type's types when they are defeq, and putting them into separate lines when not. I found it rather tediuos to parse the error message when the expected type is long, because I had to find the `:` in the middle of a large expression somewhere. Also, when both are of sort `Prop` or `Type` it doesn't add much value to print the sort (and it’s only one hover away anyways).
61 lines
1.1 KiB
Text
61 lines
1.1 KiB
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
|
|
but this term has type
|
|
Bar.fn ?_
|
|
|
|
Note: Expected a function because this term is being applied to the argument
|
|
Bp
|
|
-/
|
|
#guard_msgs in
|
|
#check fn Bp
|
|
|
|
/--
|
|
error: Function expected at
|
|
fn.imp
|
|
but this term has type
|
|
Bar.fn ?_
|
|
|
|
Note: Expected a function because this term is being applied to the argument
|
|
p
|
|
-/
|
|
#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: In the application
|
|
fn'.imp p
|
|
the argument
|
|
p
|
|
has type
|
|
P
|
|
but is expected to have type
|
|
Bar.fn ?_
|
|
-/
|
|
#guard_msgs in
|
|
#check fn' p
|