This commit is contained in:
eiei114 2023-06-25 17:14:02 +09:00
parent 14ac58f781
commit f43e346897
No known key found for this signature in database
GPG key ID: C740FAA53EE7B995
5 changed files with 656 additions and 554 deletions

1186
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -30,6 +30,7 @@ roc_reporting = { path = "../reporting" }
roc_std = { path = "../roc_std" } roc_std = { path = "../roc_std" }
roc_target = { path = "../compiler/roc_target" } roc_target = { path = "../compiler/roc_target" }
roc_types = { path = "../compiler/types" } roc_types = { path = "../compiler/types" }
roc_error_macros = { path = "../error_macros" }
bumpalo.workspace = true bumpalo.workspace = true
const_format.workspace = true const_format.workspace = true

View file

@ -3,6 +3,7 @@ use inkwell::context::Context;
use libloading::Library; use libloading::Library;
use roc_build::link::llvm_module_to_dylib; use roc_build::link::llvm_module_to_dylib;
use roc_collections::all::MutSet; use roc_collections::all::MutSet;
use roc_error_macros::internal_error;
use roc_gen_llvm::llvm::build::LlvmBackendMode; use roc_gen_llvm::llvm::build::LlvmBackendMode;
use roc_gen_llvm::llvm::externs::add_default_roc_externs; use roc_gen_llvm::llvm::externs::add_default_roc_externs;
use roc_gen_llvm::{run_jit_function, run_jit_function_dynamic_type}; use roc_gen_llvm::{run_jit_function, run_jit_function_dynamic_type};
@ -263,7 +264,7 @@ fn mono_module_to_dylib<'a>(
if main_fn.verify(true) { if main_fn.verify(true) {
function_pass.run_on(&main_fn); function_pass.run_on(&main_fn);
} else { } else {
panic!("Main function {} failed LLVM verification in build. Uncomment things nearby to see more details.", main_fn_name); internal_error!("Main function {} failed LLVM verification in build. Uncomment things nearby to see more details.", main_fn_name);
} }
module_pass.run_on(env.module); module_pass.run_on(env.module);
@ -273,10 +274,7 @@ fn mono_module_to_dylib<'a>(
// Verify the module // Verify the module
if let Err(errors) = env.module.verify() { if let Err(errors) = env.module.verify() {
panic!( internal_error!("Errors defining module:\n{}", errors.to_string());
"Errors defining module:\n{}\n\nUncomment things nearby to see more details.",
errors.to_string()
);
} }
llvm_module_to_dylib(env.module, &target, opt_level) llvm_module_to_dylib(env.module, &target, opt_level)

View file

@ -93,6 +93,7 @@ pub fn get_values<'a>(
mod test { mod test {
use indoc::indoc; use indoc::indoc;
use pretty_assertions::assert_eq; use pretty_assertions::assert_eq;
use roc_error_macros::internal_error;
use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib}; use roc_gen_llvm::{llvm::build::LlvmBackendMode, run_roc::RocCallResult, run_roc_dylib};
use roc_load::{ExecutionMode, LoadConfig, LoadMonomorphizedError, Threading}; use roc_load::{ExecutionMode, LoadConfig, LoadMonomorphizedError, Threading};
use roc_packaging::cache::RocCacheDir; use roc_packaging::cache::RocCacheDir;
@ -136,9 +137,9 @@ mod test {
) { ) {
Ok(m) => m, Ok(m) => m,
Err(LoadMonomorphizedError::ErrorModule(m)) => { Err(LoadMonomorphizedError::ErrorModule(m)) => {
panic!("{:?}", (m.can_problems, m.type_problems)) internal_error!("{:?}", (m.can_problems, m.type_problems))
} }
Err(e) => panic!("{e:?}"), Err(e) => internal_error!("{e:?}"),
}; };
let mut loaded = loaded; let mut loaded = loaded;

View file

@ -327,7 +327,7 @@ fn run_expect_fx<'a, W: std::io::Write>(
try_run_jit_function!(lib, expect.name, (), |v: ()| v); try_run_jit_function!(lib, expect.name, (), |v: ()| v);
if let Err((msg, _)) = result { if let Err((msg, _)) = result {
panic!("roc panic {}", msg); internal_error!("roc panic {}", msg);
} }
if sequence.count_failures() > 0 { if sequence.count_failures() > 0 {
@ -518,7 +518,7 @@ fn render_dbg_failure<'a>(
let data = expectations.get_mut(&module_id).unwrap(); let data = expectations.get_mut(&module_id).unwrap();
let current = match data.dbgs.get(&dbg_symbol) { let current = match data.dbgs.get(&dbg_symbol) {
None => panic!("region {failure_region:?} not in list of dbgs"), None => internal_error!("region {failure_region:?} not in list of dbgs"),
Some(current) => current, Some(current) => current,
}; };
let failure_region = current.region; let failure_region = current.region;
@ -565,7 +565,7 @@ fn render_expect_failure<'a>(
let data = expectations.get_mut(&module_id).unwrap(); let data = expectations.get_mut(&module_id).unwrap();
let current = match data.expectations.get(&failure_region) { let current = match data.expectations.get(&failure_region) {
None => panic!("region {failure_region:?} not in list of expects"), None => internal_error!("region {failure_region:?} not in list of expects"),
Some(current) => current, Some(current) => current,
}; };
@ -638,7 +638,7 @@ impl ExpectSequence {
0 => std::hint::spin_loop(), 0 => std::hint::spin_loop(),
1 => break ChildProcessMsg::Expect, 1 => break ChildProcessMsg::Expect,
2 => break ChildProcessMsg::Dbg, 2 => break ChildProcessMsg::Dbg,
n => panic!("invalid atomic value set by the child: {:#x}", n), n => internal_error!("invalid atomic value set by the child: {:#x}", n),
} }
} }
} }
@ -815,7 +815,7 @@ pub fn expect_mono_module_to_dylib<'a>(
if let Err(errors) = env.module.verify() { if let Err(errors) = env.module.verify() {
let path = std::env::temp_dir().join("test.ll"); let path = std::env::temp_dir().join("test.ll");
env.module.print_to_file(&path).unwrap(); env.module.print_to_file(&path).unwrap();
panic!( internal_error!(
"Errors defining module:\n{}\n\nUncomment things nearby to see more details. IR written to `{:?}`", "Errors defining module:\n{}\n\nUncomment things nearby to see more details. IR written to `{:?}`",
errors.to_string(), path, errors.to_string(), path,
); );