mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-23 14:35:12 +00:00
make file loading errors that happen late in compilation still fatal
This commit is contained in:
parent
21d063da26
commit
8f4945f286
9 changed files with 189 additions and 114 deletions
|
@ -1,3 +1,6 @@
|
|||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use roc_collections::all::MutSet;
|
||||
use roc_module::called_via::BinOp;
|
||||
use roc_module::ident::{Ident, Lowercase, ModuleName, TagName};
|
||||
|
@ -204,11 +207,15 @@ pub enum Problem {
|
|||
OverAppliedCrash {
|
||||
region: Region,
|
||||
},
|
||||
FileProblem {
|
||||
filename: PathBuf,
|
||||
error: io::ErrorKind,
|
||||
},
|
||||
}
|
||||
|
||||
impl Problem {
|
||||
pub fn severity(&self) -> Severity {
|
||||
use Severity::{RuntimeError, Warning};
|
||||
use Severity::{Fatal, RuntimeError, Warning};
|
||||
|
||||
match self {
|
||||
Problem::UnusedDef(_, _) => Warning,
|
||||
|
@ -269,6 +276,7 @@ impl Problem {
|
|||
Problem::UnappliedCrash { .. } => RuntimeError,
|
||||
Problem::OverAppliedCrash { .. } => RuntimeError,
|
||||
Problem::DefsOnlyUsedInRecursion(_, _) => Warning,
|
||||
Problem::FileProblem { .. } => Fatal,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,6 +422,7 @@ impl Problem {
|
|||
| Problem::RuntimeError(RuntimeError::VoidValue)
|
||||
| Problem::RuntimeError(RuntimeError::ExposedButNotDefined(_))
|
||||
| Problem::RuntimeError(RuntimeError::NoImplementationNamed { .. })
|
||||
| Problem::FileProblem { .. }
|
||||
| Problem::ExposedButNotDefined(_) => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ pub mod can;
|
|||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Severity {
|
||||
/// This should stop compilation in all cases.
|
||||
/// Due to delayed loading of ingested files, this is wanted behaviour over a runtime error.
|
||||
Fatal,
|
||||
|
||||
/// This will cause a runtime error if some code get srun
|
||||
/// (e.g. type mismatch, naming error)
|
||||
RuntimeError,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue