fix: disable panic messages during initialization

This is a temporary workaround until we implement #467.
Fixes #534
This commit is contained in:
Leonardo de Moura 2021-06-29 14:38:55 -07:00
parent 730c3e2db9
commit 2018dc0959
3 changed files with 17 additions and 0 deletions

View file

@ -158,7 +158,11 @@ def emitMainFn : M Unit := do
else
emitLn "lean_initialize_runtime_module();"
let modName ← getModName
/- We disable panic messages because they do not mesh well with extracted closed terms.
See issue #534. We can remove this workaround after we implement issue #467. -/
emitLn "lean_set_panic_messages(false);"
emitLn ("res = " ++ mkModuleInitializationFunctionName modName ++ "(lean_io_mk_world());")
emitLn "lean_set_panic_messages(true);"
emitLns ["lean_io_mark_end_initialization();",
"if (lean_io_result_is_ok(res)) {",
"lean_dec_ref(res);",

12
tests/compiler/534.lean Normal file
View file

@ -0,0 +1,12 @@
def foo (array : Array Nat) : Nat -> Nat
| 0 => 0
| n + 1 =>
let array := array.filter (!.==5)
if array.isEmpty then
0
else
let arrayOfLast := #[array.back]
foo arrayOfLast n
def main : IO Unit :=
IO.println ("hi")

View file

@ -0,0 +1 @@
hi