Report errors without mono when roc foo.roc has errors

This commit is contained in:
Ayaz Hafiz 2022-08-16 10:36:20 -05:00
parent b809d6d452
commit 7c6d811769
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
4 changed files with 146 additions and 74 deletions

View file

@ -54,6 +54,28 @@ pub fn load_single_threaded<'a>(
)
}
#[derive(Debug)]
pub enum LoadMonomorphizedError<'a> {
LoadingProblem(LoadingProblem<'a>),
/// Errors in the module that should be reported, without compiling the executable.
/// Relevant in check-and-then-build mode.
ErrorModule(LoadedModule),
}
impl<'a> From<LoadingProblem<'a>> for LoadMonomorphizedError<'a> {
fn from(problem: LoadingProblem<'a>) -> Self {
Self::LoadingProblem(problem)
}
}
// HACK only relevant because of some uses of `map_err` that decay into this error, but call `todo` -
// rustc seems to be unhappy with that.
impl<'a> From<()> for LoadMonomorphizedError<'a> {
fn from(_: ()) -> Self {
todo!()
}
}
#[allow(clippy::too_many_arguments)]
pub fn load_and_monomorphize_from_str<'a>(
arena: &'a Bump,
@ -78,14 +100,14 @@ pub fn load_and_monomorphize(
filename: PathBuf,
exposed_types: ExposedByModule,
load_config: LoadConfig,
) -> Result<MonomorphizedModule<'_>, LoadingProblem<'_>> {
) -> Result<MonomorphizedModule<'_>, LoadMonomorphizedError<'_>> {
use LoadResult::*;
let load_start = LoadStart::from_path(arena, filename, load_config.render)?;
match load(arena, load_start, exposed_types, load_config)? {
Monomorphized(module) => Ok(module),
TypeChecked(_) => unreachable!(""),
TypeChecked(module) => Err(LoadMonomorphizedError::ErrorModule(module)),
}
}