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.
39 lines
548 B
Text
39 lines
548 B
Text
inductive Enum where | a | b | c | d
|
|
|
|
/--
|
|
error: Missing cases:
|
|
Enum.d
|
|
Enum.c
|
|
-/
|
|
#guard_msgs in
|
|
def test : Enum → Nat
|
|
| .a => 0
|
|
| .b => 0
|
|
|
|
/--
|
|
error: Missing cases:
|
|
_, false
|
|
-/
|
|
#guard_msgs in
|
|
def test2 : Enum → Bool → Nat
|
|
| .a, _ => 0
|
|
| _, true => 0
|
|
|
|
/--
|
|
error: Missing cases:
|
|
(some _), false
|
|
-/
|
|
#guard_msgs in
|
|
def test3 : Option Enum → Bool → Nat
|
|
| none, _ => 0
|
|
| some .a, _ => 0
|
|
| some _, true => 0
|
|
|
|
/--
|
|
error: Missing cases:
|
|
_, false
|
|
-/
|
|
#guard_msgs in
|
|
def test4 : String → Bool → Nat
|
|
| "a", _ => 0
|
|
| _, true => 0
|