Closes #5634. Before assigning the simplified `using` clause expression to the goal, this adds a check that the expression has no new metavariables. It also adjusts how new hypotheses are added to the goal to prevent spurious "don't know how to synthesize placeholder" errors on that goal metavariable. We also throw in an occurs check immediately after elaboration to avoid some counterintuitive behavior when simplifying such a term closes the goal. Closes #4101. This also improves the type mismatch error message, showing the elaborated `using` clause rather than `h✝`: ```lean example : False := by simpa using (fun x : True => x) /- error: type mismatch, term fun x => x after simplification has type True : Prop but is expected to have type False : Prop -/ ```
29 lines
541 B
Text
29 lines
541 B
Text
/-!
|
|
# Improved `simpa` error messages
|
|
|
|
Updated error message to show the elaborated term rather than `h✝`
|
|
-/
|
|
|
|
/--
|
|
error: type mismatch, term
|
|
hp
|
|
after simplification has type
|
|
p : Prop
|
|
but is expected to have type
|
|
p ∧ q : Prop
|
|
-/
|
|
#guard_msgs in
|
|
example (p q : Prop) (hp : p ∧ True) : p ∧ q ∧ True := by
|
|
simpa using hp
|
|
|
|
/--
|
|
error: type mismatch, term
|
|
fun x => x
|
|
after simplification has type
|
|
True : Prop
|
|
but is expected to have type
|
|
False : Prop
|
|
-/
|
|
#guard_msgs in
|
|
example : False := by
|
|
simpa using (fun x : True => x)
|