Files
lean4/tests/elab/doMatchDependent.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

42 lines
1.1 KiB
Lean4

set_option backward.do.legacy false
-- Refines the free variable `n` and the result type of the `do` block:
example (x : Nat) (n : Fin (x + 1)) : Id (Fin (x + 1)) := do
match (dependent := true) x with
| 42 => pure 40
| _ => pure n
-- Just refines the free variable `n`:
example (x : Nat) (n : Fin x) : Id Bool := do
match (dependent := true) x with
| 0 => n.elim0
| _ => pure true
/--
error: Dependent match is not supported when the result type of the `do` block ⏎
Bool
is different to the result type of the `match` ⏎
Fin (x + 1)
-/
#guard_msgs (error) in
example (x : Nat) (n : Fin (x + 1)) : Id Bool := do
let y : Fin (x + 1)
match (dependent := true) x with
| 42 => pure 40
| _ => pure 0
return y % 2 == 0
/--
error: Dependent match is not supported when the result type of the `do` block ⏎
Bool
is different to the result type of the `match` ⏎
?m.7
-/
#guard_msgs (error) in
example (x : Nat) (n : Fin (x + 1)) : Id Bool := do
let y
match (dependent := true) x with
| 42 => pure 40
| _ => pure 0
return y % 2 == 0