lean4-htt/tests/lean/terminationFailure.lean
Joachim Breitner 7d60d8b563
feat: safer #eval, and #eval! (#4810)
previously, `#eval` would happily evaluate expressions that contain
`sorry`, either explicitly or because of failing tactics. In conjunction
with operations like array access this can lead to the lean process
crashing, which isn't particularly great.

So how `#eval` will refuse to run code that (transitively) depends on
the `sorry` axiom (using the same code as `#print axioms`).

If the user really wants to run it, they can use `#eval!`.

Closes #1697
2024-07-23 15:26:56 +00:00

28 lines
324 B
Text

def f (x : Nat) : Nat :=
if h : x > 0 then
g x + 2
else
1
where
g : Nat → Nat
| 0 => 2
| x => f x * 2
#check f
#check f.g
#eval! f 0
#eval! f.g 0
inductive Foo where
| a | b | c
deriving Repr
def h (x : Nat) : Foo :=
match x with
| 0 => Foo.a
| 1 => Foo.b
| x => h x
#check h
#eval! h 0