Zulip Chat Archive
Stream: lean4
Topic: Non-fatal panics in IO
Eric Wieser (Oct 07 2025 at 19:43):
How can I make panic! behave as it does in a pure context within IO? This doesn't work:
#eval show IO Nat from do
let ohno : Nat := panic!"wat" -- panic isn't shown
return 1
#eval show IO Nat from do
pure <| panic!"wat" -- panic isn't shown
return 1
#eval show IO Nat from do
let ohno := panic!"wat" -- panic works, returns `1`
return ohno + 1
Eric Wieser (Oct 07 2025 at 19:49):
seems somewhat relevant
Aaron Liu (Oct 07 2025 at 20:03):
it seems to be getting optimized out since the value isn't used
Aaron Liu (Oct 07 2025 at 20:04):
does that not happen in a pure context too?
Eric Wieser (Oct 07 2025 at 20:12):
cc Sebastian Ullrich, since the solutions you used in lean4#7321 look like they don't work anymore, suggesting those panics are now silent
Eric Wieser (Oct 07 2025 at 20:13):
#eval show IO Nat from do
letI : Inhabited (IO Nat) := ⟨pure 1⟩
panic!"wat"
#eval show IO Nat from do
show BaseIO Unit from panic!"wat"
return 1
both work
Last updated: Dec 20 2025 at 21:32 UTC