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).
62 lines
1.1 KiB
Text
62 lines
1.1 KiB
Text
/-!
|
|
# Check types when pretty printing dot notation for structure projections
|
|
|
|
In type mismatch errors, the 'object of dot notation' might not be valid for dot notation.
|
|
-/
|
|
|
|
structure Foo : Type where
|
|
out : Nat
|
|
|
|
/-!
|
|
Was printing `true.out`, but it should have been `Foo.out true`.
|
|
-/
|
|
/--
|
|
error: Application type mismatch: In the application
|
|
Foo.out true
|
|
the argument
|
|
true
|
|
has type
|
|
Bool
|
|
but is expected to have type
|
|
Foo
|
|
---
|
|
info: sorry.out : Nat
|
|
-/
|
|
#guard_msgs in #check Foo.out true
|
|
|
|
/-!
|
|
Verifying that generalized field notation does not have this bug.
|
|
-/
|
|
def Foo.out' (f : Foo) : Nat := f.out
|
|
/--
|
|
error: Application type mismatch: In the application
|
|
Foo.out' true
|
|
the argument
|
|
true
|
|
has type
|
|
Bool
|
|
but is expected to have type
|
|
Foo
|
|
---
|
|
info: sorry.out' : Nat
|
|
-/
|
|
#guard_msgs in #check Foo.out' true
|
|
|
|
/-!
|
|
Verifying that projection notation still pretty prints as normal.
|
|
-/
|
|
section
|
|
variable (f : Foo)
|
|
/-- info: f.out : Nat -/
|
|
#guard_msgs in #check f.out
|
|
end
|
|
|
|
/-!
|
|
Verifying that projection notation still pretty prints through type synonys.
|
|
-/
|
|
section
|
|
def Baz := Foo
|
|
variable (f : Baz)
|
|
/-- info: f.out : Nat -/
|
|
#guard_msgs in #check f.out
|
|
end
|