lean4-htt/tests/lean/run/exposeDiff.lean
Joachim Breitner 8424ddbb3e
feat: prettier expected type mismatch error message (#9099)
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).
2025-07-01 07:50:53 +00:00

49 lines
1.1 KiB
Text

/--
error: tactic 'apply' failed, could not unify the type of `x`
PUnit.{1}
with the goal
PUnit.{0}
x : PUnit
⊢ PUnit
-/
#guard_msgs in
example (x : PUnit.{1}) : PUnit.{0} := by
apply x
/--
error: type mismatch
x
has type
PUnit.{1}
of sort `Type` but is expected to have type
PUnit.{0}
of sort `Prop`
-/
#guard_msgs in
example (x : PUnit.{1}) : PUnit.{0} :=
x
/--
error: tactic 'rfl' failed, the left-hand side
∀ (x : PUnit.{1}), True
is not definitionally equal to the right-hand side
∀ (x : PUnit.{2}), True
⊢ (∀ (x : PUnit), True) ↔ ∀ (x : PUnit), True
-/
#guard_msgs in
example : (∀ _ : PUnit.{1}, True) ↔ ∀ _ : PUnit.{2}, True := by
rfl
inductive Test where
| mk (x : Prop)
/--
error: tactic 'rfl' failed, the left-hand side
(Test.mk (∀ (x : PUnit.{1}), True)).1
is not definitionally equal to the right-hand side
(Test.mk (∀ (x : PUnit.{2}), True)).1
⊢ (Test.mk (∀ (x : PUnit), True)).1 = (Test.mk (∀ (x : PUnit), True)).1
-/
#guard_msgs in
example : (Test.mk (∀ _ : PUnit.{1}, True)).1 = (Test.mk (∀ _ : PUnit.{2}, True)).1 := by
rfl