lean4-htt/tests/lean/run/1697.lean
Kyle Miller 69c71f6476
fix: make elabAsElim aware of explicit motive arguments (#4817)
Some eliminators (such as `False.rec`) have an explicit motive argument.
The `elabAsElim` elaborator assumed that all motives are implicit.

If the explicit motive argument is `_`, then it uses the elab-as-elim
procedure, and otherwise it falls back to the standard app elaborator.

Furthermore, if an explicit elaborator is not provided, it falls back to
treating the elaborator as being implicit, which is convenient for
writing `h.rec` rather than `h.rec _`. Rationale: for `False.rec`, this
simulates it having an implicit motive, and also motives are generally
not going to be available in the expected type.

Closes #4347
2024-07-29 19:18:47 +00:00

45 lines
964 B
Text

/--
error: tactic 'decide' proved that the proposition
False
is false
---
error: cannot evaluate expression that depends on the `sorry` axiom.
Use `#eval!` to evaluate nevertheless (which may cause lean to crash).
-/
#guard_msgs in
#eval show Nat from False.elim (by decide)
/--
warning: declaration uses 'sorry'
---
error: cannot evaluate expression that depends on the `sorry` axiom.
Use `#eval!` to evaluate nevertheless (which may cause lean to crash).
-/
#guard_msgs in
#eval #[1,2,3][2]'sorry
/--
warning: declaration uses 'sorry'
---
info: 3
-/
#guard_msgs in
#eval! #[1,2,3][2]'sorry
/-
With this test I wanted to show that `#eval!` can be used to do unsafe operations. Under
normal circumstances this actually works with the output below, but the `Linux Debug` CI build
catches it and complains. Maybe too bold to have this in the test suite.
/--
warning: declaration uses 'sorry'
---
info: 3
-/
#guard_msgs in
#eval! (#[1,2,3].pop)[2]'sorry
-/