lean4-htt/tests/lean/run/8815.lean
jrr6 5f4e6a86d5
feat: update and explain "unknown constant" and "failed to infer type" errors (#9423)
This PR updates the formatting of, and adds explanations for, "unknown
identifier" errors as well as "failed to infer type" errors for binders
and definitions.

It attempts to ameliorate some of the confusion encountered in #1592 by
modifying the wording of the "header is elaborated before body is
processed" note and adding further discussion and examples of this
behavior in the corresponding error explanation.
2025-07-18 19:20:31 +00:00

62 lines
1.4 KiB
Text

/-!
Assortion of tests to make sure the #8815 simp arg elaboration refactoring did not change
behavior.
-/
set_option linter.unusedVariables false
example (P Q : Prop) (hQ : Q) (hP : P) : P := by simp [*, -hQ]
/-- error: simp made no progress -/
#guard_msgs in example (P Q : Prop) (hQ : Q) (hP : P) : P := by simp [*, -hP]
/-- error: Unknown constant `hQ` -/
#guard_msgs in example (P Q : Prop) (hQ : Q) (hP : P) : P := by simp [-hQ, *]
#guard_msgs in example (P Q : Prop) (hQ : Q) (hP : P) : P := by simp_all [-hQ]
/--
error: Unknown constant `hQ`
---
error: simp made no progress
-/
#guard_msgs in example (P Q : Prop) (hQ : Q) (hP : P) : P := by simp [-hQ]
theorem a_thm : True := trivial
def f : Nat → Nat
| 0 => 1
| n + 1 => f n + 1
example : f 0 > 0 := by simp [f]
example : f 0 > 0 := by simp!
-- NB: simp! disables all warnings, not just for declarations to unfold
-- Mild bug, but not a regresion.
/--
error: unsolved goals
⊢ 0 < f 0
-/
#guard_msgs in example : f 0 > 0 := by simp! [-f, -a_thm]
/--
warning: 'f' does not have [simp] attribute
---
warning: 'a_thm' does not have [simp] attribute
---
error: unsolved goals
⊢ 0 < f 0
-/
#guard_msgs in example : f 0 > 0 := by
simp [-f, -a_thm]
/--
error: invalid 'simp', proposition expected
Type 32
-/
#guard_msgs in
example : True := by simp [Sort 32] -- mostly about error location, once guard_msgs shows that