lean4-htt/tests/lean/run/issue11695.lean
Joachim Breitner 118160bf07
refactor: handle irrefutable patterns in match compilation individually (#11695)
This PR refactors match compilation, to handle “side-effect free”
patterns (`.var`, `.inaccessible`, `.as`) eagerly and for each
alternative separately. The idea is that there should be less interplay
between different alternatives, and prepares the ground for #11105.

This may cause some corner case match statements to compiler or fail
compile that behaved differently before. For example, it can now use a
sparse case where previously was using a full case, and pattern
completeness may not be clear to lean now. On the other hand, using a
sparse case can mean that match statements mixing matching in indicies
with matching on the indexed datatype can work.
2025-12-17 09:02:17 +00:00

24 lines
594 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-! Regression tests from working on PR 11695 -/
set_option linter.unusedVariables false
-- set_option trace.Meta.Match.match true
def dependent : (n : Nat) → (m : Fin n) → Nat
| 0, i => Fin.elim0 i
| .succ 0, 0 => 0
| .succ (.succ n), 0 => 1
| .succ (.succ n), ⟨.succ m, h⟩ => 2
inductive Vec (α : Type) : Nat → Type where
| nil : Vec α 0
| cons : α → Vec α n → Vec α (n + 1)
def f1 : {n : Nat} → (v : Vec α n) → Nat
| 0, _ => 0
| _, .cons x xs => 1
def f2 : {n : Nat} → (v : Vec α n) → Nat
| _, Vec.nil => 0
| .succ n, _ => 1