lean4-htt/tests/lean/run/3713.lean
Leonardo de Moura 0684c95d35
fix: do not lift (<- ...) over pure if-then-else (#3820)
Now, only `(<- ...)`s occurring in the condition of a pure if-then-else
are lifted.
That is, `if (<- foo) then ... else ...` is ok, but `if ... then (<-
foo) else ...` is not. See #3713

closes #3713 

This PR also adjusts this repo. Note that some of the `(<- ...)` were
harmless since they were just accessing some
read-only state.
2024-04-01 21:33:59 +00:00

35 lines
626 B
Text

import Lean
open Lean Elab Meta
def somethingBad : MetaM Nat := do
IO.println "oh no"
return 1
/--
error: invalid use of `(<- ...)`, must be nested inside a 'do' expression
---
info:
-/
#guard_msgs in
#eval show MetaM Unit from do
let t := if false then ← somethingBad else 9
def foo : MetaM Bool :=
return false
/--
error: invalid use of `(<- ...)`, must be nested inside a 'do' expression
---
info:
-/
#guard_msgs in
#eval show MetaM Unit from do
let t := if (← foo) then ← somethingBad else 9
/--
info: 1
-/
#guard_msgs in
#eval show MetaM Nat from do
let t := if (← foo) then 0 else 1
return t