lean4-htt/tests/elab/try_panic.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

35 lines
1.1 KiB
Text

import Lean
/-!
# Regression test: getEqnsFor? should not panic on matchers
Previously, when a theorem had a match expression in its type (e.g. `bar.match_1`),
calling `getEqnsFor?` on the matcher would panic with "duplicate normalized declaration name".
This was fixed by making `shouldGenerateEqnThms` return `false` for matchers, since
matcher equations are handled separately by `Lean.Meta.Match.MatchEqs`.
-/
-- A theorem with a match expression in its type creates a matcher `bar.match_1`
theorem bar : (match (0 : Nat) with | 0 => 0 | _ => 1) = 0 := by native_decide
-- getEqnsFor? on a matcher should return none (not panic)
/-- info: eqns: none -/
#guard_msgs in
#eval do
let eqns ← Lean.Meta.getEqnsFor? `bar.match_1
IO.println s!"eqns: {eqns}"
-- try? should not panic when encountering matchers in the goal
-- (it may fail to find suggestions, but should not panic)
/--
info: Try these:
[apply] rfl
[apply] simp
[apply] simp only
[apply] grind
[apply] grind only
[apply] simp_all
-/
#guard_msgs in
theorem bar' : (match (0 : Nat) with | 0 => 0 | _ => 1) = 0 := by try?