mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-22 21:04:07 +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
|
@ -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