Eliminate Stmt::RuntimeError in favor of crash

This commit is contained in:
Ayaz Hafiz 2022-11-22 18:08:33 -06:00
parent a2f2a18a76
commit 803d7e30e3
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
14 changed files with 115 additions and 130 deletions

View file

@ -1,5 +1,6 @@
use core::ffi::c_void;
use roc_mono::ir::CrashTag;
use roc_std::RocStr;
/// # Safety
@ -39,14 +40,12 @@ pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
/// The Roc application needs this.
#[no_mangle]
pub unsafe fn roc_panic(msg: &RocStr, tag_id: u32) {
use roc_gen_llvm::llvm::build::PanicTagId;
match PanicTagId::try_from(tag_id) {
Ok(PanicTagId::RocPanic) => {
match CrashTag::try_from(tag_id) {
Ok(CrashTag::Roc) => {
eprintln!("Roc hit a panic: {}", msg);
std::process::exit(1);
}
Ok(PanicTagId::UserPanic) => {
Ok(CrashTag::User) => {
eprintln!("User panic: {}", msg);
std::process::exit(1);
}