diff --git a/cli/src/repl/gen.rs b/cli/src/repl/gen.rs index 1d9427842a..be27087b38 100644 --- a/cli/src/repl/gen.rs +++ b/cli/src/repl/gen.rs @@ -131,11 +131,15 @@ pub fn gen_and_eval(src: &[u8], target: Triple, opt_level: OptLevel) -> Result layout.clone(), + None => { + return Ok(ReplOutput::NoProblems { + expr: "".to_string(), + expr_type: expr_type_str, + }); + } + }; let ptr_bytes = target.pointer_width().unwrap().bytes() as u32; diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index fd61954feb..1425b8b921 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -20,7 +20,7 @@ use roc_module::symbol::{ use roc_mono::ir::{ CapturedSymbols, ExternalSpecializations, PartialProc, PendingSpecialization, Proc, Procs, }; -use roc_mono::layout::{Layout, LayoutCache}; +use roc_mono::layout::{Layout, LayoutCache, LayoutProblem}; use roc_parse::ast::{self, Attempting, StrLiteral, TypeAnnotation}; use roc_parse::header::{ ExposesEntry, ImportsEntry, PackageEntry, PackageOrPath, PlatformHeader, To, TypedIdent, @@ -3503,9 +3503,20 @@ fn add_def_to_module<'a>( mono_env.subs, ) { Ok(l) => l, - Err(err) => { - // a host-exposed function is not monomorphized - todo!("The host-exposed function {:?} does not have a valid layout (e.g. maybe the function wasn't monomorphic): {:?}", symbol, err) + Err(LayoutProblem::Erroneous) => { + let message = "top level function has erroneous type"; + procs.runtime_errors.insert(symbol, message); + return; + } + Err(LayoutProblem::UnresolvedTypeVar(v)) => { + let message = format!( + "top level function has unresolved type variable {:?}", + v + ); + procs + .runtime_errors + .insert(symbol, mono_env.arena.alloc(message)); + return; } }; diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index dc08c98176..f5e2f0b0ca 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -1508,7 +1508,6 @@ pub fn specialize_all<'a>( )); procs.runtime_errors.insert(name, error_msg); - panic!("failed to specialize {:?}", name); } } }