#[non_exhaustive]pub enum AstConversionError {
EmbeddedQuantifier,
FreeLengthVar(String),
FreeTypeVar(String),
UnusedLength(String),
UnusedTypeParam(String),
UnknownType(String),
UnknownConstraint(String),
InvalidSomeType,
InvalidSomeLength,
DuplicateField(String),
NotObjectSafe(String),
}Expand description
Kinds of errors that can occur when converting *Ast types into their “main” counterparts.
During type inference, errors of this type are wrapped into the AstConversion
variant of typing errors.
§Examples
use arithmetic_parser::grammars::{Parse, F32Grammar};
use arithmetic_typing::{
ast::AstConversionError, error::ErrorKind, Annotated, TypeEnvironment,
};
let code = "bogus_slice: ['T; _] = (1, 2, 3);";
let ast = Annotated::<F32Grammar>::parse_statements(code)?;
let errors = TypeEnvironment::new().process_statements(&ast).unwrap_err();
let err = errors.into_iter().next().unwrap();
assert_eq!(err.main_location().span(code), "'T");
assert_matches!(
err.kind(),
ErrorKind::AstConversion(AstConversionError::FreeTypeVar(id))
if id == "T"
);Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
EmbeddedQuantifier
Embedded param quantifiers.
FreeLengthVar(String)
Length param not scoped by a function.
FreeTypeVar(String)
Type param not scoped by a function.
UnusedLength(String)
Unused length param.
UnusedTypeParam(String)
Unused length param.
UnknownType(String)
Unknown type name.
UnknownConstraint(String)
Unknown constraint.
InvalidSomeType
Some type (_) encountered when parsing a standalone type.
_ types are only allowed in the context of a TypeEnvironment. It is a logical
error to use them when parsing standalone types.
InvalidSomeLength
Some length (_) encountered when parsing a standalone type.
_ lengths are only allowed in the context of a TypeEnvironment. It is a logical
error to use them when parsing standalone types.
DuplicateField(String)
Field with the same name is defined multiple times in an object type.
NotObjectSafe(String)
Constraint is not object-safe.
Trait Implementations§
Source§impl Clone for AstConversionError
impl Clone for AstConversionError
Source§fn clone(&self) -> AstConversionError
fn clone(&self) -> AstConversionError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AstConversionError
impl Debug for AstConversionError
Source§impl Display for AstConversionError
impl Display for AstConversionError
Source§impl Error for AstConversionError
Available on crate feature std only.
impl Error for AstConversionError
std only.