- Renamed "intrinsic" -> "primitive" - I thought it was funny, but it's just annoying. - Rename "Uninferred" -> "Inferred" - It's a concrete type, but an inferred one. - Add lifetimes to the Entry API - Categorize does not care about recursive types. You can't have a recursive AST. - Added helpful constructors to the inference engine - Added some overloadable operators to the inference engine - These are a MAJOR work in progress - Reorganized the Inference implementation file by functionality. stdlib: - Updated standard library.
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
use cl_ast::Path;
|
|
|
|
use crate::handle::Handle;
|
|
use core::fmt;
|
|
|
|
/// An error produced during type inference
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum InferenceError {
|
|
AnnotationEval(crate::type_expression::Error),
|
|
FieldCount(Handle, usize, usize),
|
|
NotFound(Path),
|
|
Mismatch(Handle, Handle),
|
|
Recursive(Handle, Handle),
|
|
}
|
|
|
|
impl std::error::Error for InferenceError {}
|
|
#[rustfmt::skip]
|
|
impl fmt::Display for InferenceError {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
match self {
|
|
InferenceError::AnnotationEval(error) => write!(f, "{error}"),
|
|
InferenceError::FieldCount(name, want, got) => {
|
|
write!(f,
|
|
"Struct {name} {} fields! Expected {want}, got {got}",
|
|
if want < got { "has too many" } else { "is missing" }
|
|
)
|
|
}
|
|
InferenceError::NotFound(p) => write!(f, "Path not visible in scope: {p}"),
|
|
InferenceError::Mismatch(a, b) => write!(f, "Type mismatch: {a:?} != {b:?}"),
|
|
InferenceError::Recursive(_, _) => write!(f, "Recursive type!"),
|
|
}
|
|
}
|
|
}
|