cortex_lang/preprocessing/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug, PartialEq)]
4pub enum PreprocessingError {
5 #[error("Could not infer type bindings for {0} (consider manually providing bindings)")]
6 CouldNotInferTypeBinding(String),
7 #[error("Cannot have type arguments on a generic type: {0}")]
8 CannotHaveTypeArgsOnGeneric(String),
9 #[error("Expected type {0} for {2} but expression of type {1} was found (context: {3})")]
10 MismatchedType(String, String, String, String),
11 #[error("Could not determine type for list literal: expected {0} but found {1}")]
12 CannotDetermineListLiteralType(String, String),
13 #[error("Value not found: {0} (module constants are currently not supported)")]
14 ValueNotFound(String),
15 #[error("Invalid unary operator values: only the type(s) {0} are allowed")]
16 InvalidOperatorUnary(&'static str),
17 #[error("Invalid binary operator values: only the type(s) {0} and {1} are allowed")]
18 InvalidOperator(&'static str, &'static str),
19 #[error("Cannot assign multiple times to struct field {0} in construction")]
20 MultipleFieldAssignment(String),
21 #[error("Fields not assigned on struct {0}: {1}")]
22 NotAllFieldsAssigned(String, String),
23 #[error("If arm types do not match: expected {0} but found {1}")]
24 IfArmsDoNotMatch(String, String),
25 #[error("If an if arm returns a value, then there must be an else block")]
26 IfRequiresElseBlock,
27 #[error("Loop body cannot have a return value")]
28 LoopCannotHaveReturnValue,
29 #[error("Type {0} requires {1} type arguments but only {2} was/were provided")]
30 MismatchedTypeArgCount(String, usize, usize),
31 #[error("Invalid type: {0} is not valid in this context")]
32 TypeInvalidInThisContext(String),
33 #[error("Cannot modify value \"{0}\" if it comes from a module")]
34 CannotModifyModuleEnvironment(String),
35 #[error("Mismatched argument count: Function {0} expects {1} arguments but received {2}")]
36 MismatchedArgumentCount(String, usize, usize),
37 #[error("Parent environment not found")]
38 NoParentEnv,
39 #[error("Cannot modify constant variable {0}")]
40 CannotModifyConst(String),
41 #[error("Function declared to return {0} but actually returns {1}")]
42 ReturnTypeMismatch(String, String),
43 #[error("Field \"{0}\" does not exist on type {1}")]
44 FieldDoesNotExist(String, String),
45 #[error("You cannot access fields on a non-composite value")]
46 CannotAccessMemberOfNonComposite,
47 #[error("Cannot modify field on immutable reference for type {0}")]
48 CannotModifyFieldOnImmutableReference(String),
49 #[error("Unknown type found!")]
50 UnknownTypeFound,
51 #[error("`break` used in a non-loop context! Can only use within loops!")]
52 BreakUsedInNonLoopContext,
53 #[error("`continue` used in a non-loop context! Can only use within loops!")]
54 ContinueUsedInNonLoopContext,
55 #[error("Tuple elements must be accessed in this form: .t{{index}}. {0} is an invalid tuple member access")]
56 TupleMemberSyntaxInvalid(String),
57 #[error("Tuple has size of {0} but index {1} was attempted to index into it!")]
58 TupleIndexValueInvalid(usize, usize),
59 #[error("Ambiguous function call: Multiple extension functions named {0} defined on type {1}")]
60 AmbiguousExtensionCall(String, String),
61 #[error("Cannot access members on optional value: {0} (consider using `!` to assert it is not `none`")]
62 CannotAccessMemberOfOptional(String),
63 #[error("Struct \"{0}\" contains at least one field that references back to itself")]
64 StructContainsCircularFields(String),
65 #[error("Type \"{0}\" does not exist")]
66 TypeDoesNotExist(String),
67 #[error("Function \"{0}\" was not found")]
68 FunctionDoesNotExist(String),
69}