lean4-htt/tests/lean/dbgMacros.lean
Leonardo de Moura 9538772c1c chore: do not use string interpolation by default at dbgTrace!
It is nice to be able to write `dbgTrace! x` instead of `dbgTrace! "{x}"`
2020-10-09 20:49:39 -07:00

34 lines
388 B
Text

new_frontend
def f (x : Nat) :=
if x = 0 then panic! "unexpected zero"
else x - 1
#eval f 0
#eval f 10
def g (x : Nat) :=
if x = 0 then unreachable!
else x - 1
#eval g 0
def h (x : Nat) :=
assert! x != 0;
x - 1
#eval h 1
#eval h 0
def f2 (x : Nat) :=
dbgTrace! s!"f2, x: {x}";
x + 1
#eval f2 10
def g2 (x : Nat) : IO Nat := do
IO.println "g2 started";
pure (x + 1)
#eval g2 10