lean4-htt/tests/lean/run/premise_selection.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

39 lines
891 B
Text

import Lean.PremiseSelection
/--
error: type mismatch
Nat
has type
Type
of sort `Type 1` but is expected to have type
Lean.PremiseSelection.Selector
of sort `Type`
---
error: Failed to elaborate Nat as a `MVarId → Config → MetaM (Array Suggestion)`.
-/
#guard_msgs in
set_premise_selector Nat
/--
error: No premise selector registered. (Note the Lean does not provide a default premise selector, these must be installed by a downstream library.)
-/
#guard_msgs in
example : True := by
suggest_premises
trivial
set_premise_selector (fun _ _ => pure #[])
/-- info: Premise suggestions: [] -/
#guard_msgs in
example : True := by
suggest_premises
trivial
set_premise_selector Lean.PremiseSelection.random ⟨1,1⟩
-- This would be an extremely fragile test (select 10 random constants!)
-- so we do not use #guard_msgs.
example : True := by
suggest_premises
trivial