swamp_script_analyzer/
err.rs1use std::num::{ParseFloatError, ParseIntError};
7use swamp_script_node::Node;
8use swamp_script_semantic::SemanticError;
9use swamp_script_types::prelude::*;
10
11#[derive(Debug)]
12pub struct Error {
13 pub node: Node,
14 pub kind: ErrorKind,
15}
16#[derive(Debug)]
17pub enum ErrorKind {
18 NoAssociatedFunction(Type, String),
19 MissingSubscriptMember,
20 UnusedVariablesCanNotBeMut,
21 VariableTypeMustBeConcrete,
22 GuardCanNotHaveMultipleWildcards,
23 WildcardMustBeLastInGuard,
24 GuardMustHaveWildcard,
25 GuardHasNoType,
26 TooManyDestructureVariables,
27 CanNotDestructure,
28 UnknownStructTypeReference,
29 DuplicateFieldName,
30 MissingFieldInStructInstantiation(Vec<String>, AnonymousStructType),
31 UnknownVariable,
32 ArrayIndexMustBeInt(Type),
33 OverwriteVariableWithAnotherType,
34 NoneNeedsExpectedTypeHint,
35 ExpectedMutableLocation,
36 WrongNumberOfArguments(usize, usize),
37 CanOnlyOverwriteVariableWithMut,
38 OverwriteVariableNotAllowedHere,
39 UnknownEnumVariantType,
40 UnknownStructField,
41 UnknownEnumVariantTypeInPattern,
42 ExpectedEnumInPattern,
43 WrongEnumVariantContainer(EnumVariantType),
44 VariableIsNotMutable,
45 ArgumentIsNotMutable,
46 UnknownTypeReference,
47 SemanticError(SemanticError),
48 ExpectedOptional,
49 MapKeyTypeMismatch { expected: Type, found: Type },
50 MapValueTypeMismatch { expected: Type, found: Type },
51 IncompatibleTypes { expected: Type, found: Type },
52 UnknownMemberFunction,
53 ExpressionsNotAllowedInLetPattern,
54 UnknownField,
55 EnumVariantHasNoFields,
56 TooManyTupleFields { max: usize, got: usize },
57 ExpectedBooleanExpression,
58 NotAnIterator,
59 IntConversionError(ParseIntError),
60 FloatConversionError(ParseFloatError),
61 BoolConversionError,
62 DuplicateFieldInStructInstantiation(String),
63 UnknownIdentifier(String),
64 NoDefaultImplemented(Type),
65 UnknownConstant,
66 NotValidLocationStartingPoint,
67 CallsCanNotBePartOfChain,
68 UnwrapCanNotBePartOfChain,
69 NoneCoalesceCanNotBePartOfChain,
70 SelfNotCorrectType,
71 CanNotNoneCoalesce,
72 UnknownSymbol,
73 UnknownEnumType,
74 UnknownModule,
75 BreakOutsideLoop,
76 ReturnOutsideCompare,
77 EmptyMatch,
78 MatchArmsMustHaveTypes,
79 ContinueOutsideLoop,
80 ParameterIsNotMutable,
81 CouldNotCoerceTo(Type),
82 UnexpectedType,
83 CanNotAttachFunctionsToType,
84 MissingMemberFunction(String),
85 ExpectedLambda,
86}
87
88impl From<SemanticError> for Error {
89 fn from(value: SemanticError) -> Self {
90 Self {
91 node: Default::default(),
92 kind: ErrorKind::SemanticError(value),
93 }
94 }
95}