mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 03:42:17 +00:00
Get severity from type problem variants
This commit is contained in:
parent
5414b4b60f
commit
39f89e3d65
5 changed files with 99 additions and 37 deletions
|
@ -11,3 +11,4 @@ roc_collections = { path = "../collections" }
|
|||
roc_region = { path = "../region" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_problem = { path = "../problem" }
|
||||
|
|
|
@ -7,6 +7,7 @@ use roc_module::{
|
|||
ident::{Lowercase, TagIdIntType, TagName},
|
||||
symbol::Symbol,
|
||||
};
|
||||
use roc_problem::Severity;
|
||||
use roc_region::all::Region;
|
||||
|
||||
use self::Pattern::*;
|
||||
|
@ -149,6 +150,17 @@ pub enum Error {
|
|||
},
|
||||
}
|
||||
|
||||
impl Error {
|
||||
pub fn severity(&self) -> Severity {
|
||||
use Severity::*;
|
||||
match self {
|
||||
Error::Incomplete(..) => RuntimeError,
|
||||
Error::Redundant { .. } => Warning,
|
||||
Error::Unmatchable { .. } => Warning,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Context {
|
||||
BadArg,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Provides types to describe problems that can occur during solving.
|
||||
use roc_can::expected::{Expected, PExpected};
|
||||
use roc_module::{ident::Lowercase, symbol::Symbol};
|
||||
use roc_problem::can::CycleEntry;
|
||||
use roc_problem::{can::CycleEntry, Severity};
|
||||
use roc_region::all::Region;
|
||||
|
||||
use roc_types::types::{Category, ErrorType, PatternCategory};
|
||||
|
@ -31,6 +31,27 @@ pub enum TypeError {
|
|||
},
|
||||
}
|
||||
|
||||
impl TypeError {
|
||||
pub fn severity(&self) -> Severity {
|
||||
use Severity::*;
|
||||
match self {
|
||||
TypeError::BadExpr(..) => RuntimeError,
|
||||
TypeError::BadPattern(..) => RuntimeError,
|
||||
TypeError::CircularType(..) => RuntimeError,
|
||||
TypeError::CircularDef(_) => RuntimeError,
|
||||
TypeError::UnexposedLookup(_) => RuntimeError,
|
||||
TypeError::UnfulfilledAbility(_) => RuntimeError,
|
||||
TypeError::BadExprMissingAbility(_, _, _, _) => RuntimeError,
|
||||
TypeError::BadPatternMissingAbility(_, _, _, _) => RuntimeError,
|
||||
// NB: if bidirectional exhaustiveness checking is implemented, the other direction
|
||||
// is also not a runtime error.
|
||||
TypeError::Exhaustive(exhtv) => exhtv.severity(),
|
||||
TypeError::StructuralSpecialization { .. } => RuntimeError,
|
||||
TypeError::WrongSpecialization { .. } => RuntimeError,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Debug, Clone)]
|
||||
pub enum Unfulfilled {
|
||||
/// No claimed implementation of an ability for an opaque type.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue