Enum arithmetic_typing::error::ErrorKind
source · #[non_exhaustive]pub enum ErrorKind<Prim: PrimitiveType> {
Show 20 variants
TypeMismatch(Type<Prim>, Type<Prim>),
TupleLenMismatch {
lhs: TupleLen,
rhs: TupleLen,
context: TupleContext,
},
UndefinedVar(String),
RecursiveType(Type<Prim>),
RepeatedAssignment(String),
InvalidFieldName(String),
CannotIndex,
UnsupportedIndex,
IndexOutOfBounds {
index: usize,
len: TupleLen,
},
RepeatedField(String),
CannotAccessFields,
FieldsMismatch {
lhs_fields: HashSet<String>,
rhs_fields: HashSet<String>,
},
MissingFields {
fields: HashSet<String>,
available_fields: HashSet<String>,
},
UnresolvedParam,
FailedConstraint {
ty: Type<Prim>,
constraint: Box<dyn Constraint<Prim>>,
},
DynamicLen(TupleLen),
UnsupportedFeature(UnsupportedType),
UnsupportedType(Type<Prim>),
UnsupportedParam,
AstConversion(AstConversionError),
}
Expand description
Kinds of errors that can occur during type inference.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TypeMismatch(Type<Prim>, Type<Prim>)
Trying to unify incompatible types. The first type is LHS, the second one is RHS.
TupleLenMismatch
Incompatible tuple lengths.
Fields
lhs: TupleLen
Length of the LHS. This is the length determined by type annotations for assignments and the number of actually supplied args in function calls.
rhs: TupleLen
Length of the RHS. This is usually the actual tuple length in assignments and the number of expected args in function calls.
context: TupleContext
Context in which the error has occurred.
UndefinedVar(String)
Undefined variable occurrence.
RecursiveType(Type<Prim>)
Trying to unify a type with a type containing it.
RepeatedAssignment(String)
Repeated assignment to the same variable in function args or tuple destructuring.
InvalidFieldName(String)
Field name is invalid.
CannotIndex
Value cannot be indexed (i.e., not a tuple).
UnsupportedIndex
Unsupported indexing operation. For example, the receiver type is not known, or it is a tuple with an unknown length, and the type of the element cannot be decided.
IndexOutOfBounds
Index is out of bounds for the indexed tuple.
RepeatedField(String)
Repeated field in object initialization / destructuring.
CannotAccessFields
Cannot access fields in a value (i.e., it’s not an object).
FieldsMismatch
Field set differs between LHS and RHS, which are both concrete objects.
MissingFields
Concrete object does not have required fields.
Fields
UnresolvedParam
Mention of a bounded type or length variable in a type supplied
to Substitutions::unify()
.
Bounded variables are instantiated into free vars automatically during
type inference, so this error
can only occur with types manually supplied to Substitutions::unify()
.
FailedConstraint
Failure when applying constraint to a type.
Fields
constraint: Box<dyn Constraint<Prim>>
Failing constraint.
DynamicLen(TupleLen)
Length with the static constraint is actually dynamic (contains UnknownLen::Dynamic
).
UnsupportedFeature(UnsupportedType)
Language feature not supported by type inference logic.
UnsupportedType(Type<Prim>)
Type not supported by type inference logic. For example,
a TypeArithmetic
or Constraint
implementations may return this error
if they encounter an unknown Type
variant.
UnsupportedParam
Unsupported use of type or length params in a function declaration.
Type or length params are currently not supported in type annotations. Here’s an example of code that triggers this error:
identity: (('T,)) -> ('T,) = |x| x;
AstConversion(AstConversionError)
Error while instantiating a type from AST.
Implementations§
source§impl<Prim: PrimitiveType> ErrorKind<Prim>
impl<Prim: PrimitiveType> ErrorKind<Prim>
sourcepub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self
pub fn unsupported<T: Into<UnsupportedType>>(ty: T) -> Self
Creates an error for an lvalue type not supported by the interpreter.
sourcepub fn failed_constraint(
ty: Type<Prim>,
constraint: impl Constraint<Prim> + Clone,
) -> Self
pub fn failed_constraint( ty: Type<Prim>, constraint: impl Constraint<Prim> + Clone, ) -> Self
Creates a “failed constraint” error.
Trait Implementations§
source§impl<Prim: PrimitiveType> Display for ErrorKind<Prim>
impl<Prim: PrimitiveType> Display for ErrorKind<Prim>
source§impl<Prim: PrimitiveType> Error for ErrorKind<Prim>
impl<Prim: PrimitiveType> Error for ErrorKind<Prim>
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
Auto Trait Implementations§
impl<Prim> Freeze for ErrorKind<Prim>where
Prim: Freeze,
impl<Prim> !RefUnwindSafe for ErrorKind<Prim>
impl<Prim> Send for ErrorKind<Prim>
impl<Prim> Sync for ErrorKind<Prim>
impl<Prim> Unpin for ErrorKind<Prim>where
Prim: Unpin,
impl<Prim> !UnwindSafe for ErrorKind<Prim>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)