Enum ErrorCode
pub enum ErrorCode {
Show 51 variants
ExpectedSemicolon = 1_001,
ExpectedClosingBrace = 1_002,
ExpectedClosingParen = 1_003,
ExpectedClosingBracket = 1_004,
ExpectedOpeningBrace = 1_005,
ExpectedOpeningParen = 1_006,
ExpectedIdentifier = 1_007,
ExpectedType = 1_008,
ExpectedExpression = 1_009,
ExpectedStatement = 1_010,
ExpectedParameter = 1_011,
ExpectedAssignment = 1_012,
ExpectedComma = 1_013,
ExpectedColon = 1_014,
ExpectedEquals = 1_015,
ExpectedFunctionBody = 1_016,
ExpectedStructField = 1_017,
ExpectedEof = 1_018,
UnexpectedToken = 1_019,
InvalidNumberLiteral = 1_020,
InvalidStringLiteral = 1_021,
InvalidCharLiteral = 1_022,
InvalidEscapeSequence = 1_023,
UnterminatedString = 1_024,
UnterminatedChar = 1_025,
MalformedComment = 1_026,
InvalidToken = 1_027,
NestedFunction = 1_028,
InvalidSyntax = 1_029,
UnknownType = 1_030,
ExpectedElse = 1_031,
ExpectedClosingQuote = 1_032,
UndefinedVariable = 2_001,
VariableRedefinition = 2_002,
SymbolRedefinition = 2_003,
InvalidFieldType = 2_004,
TypeMismatch = 2_005,
OperationTypeMismatch = 2_006,
LogicalOperatorTypeMismatch = 2_007,
ValueOutOfRange = 2_008,
ArgumentCountMismatch = 2_009,
ArgumentTypeMismatch = 2_010,
ReturnOutsideFunction = 2_011,
ReturnTypeMismatch = 2_012,
MissingReturnValue = 2_013,
UndefinedFunction = 2_014,
InvalidUnaryOperation = 2_015,
AssignmentToImmutableVariable = 2_016,
InvalidExpression = 2_017,
VariableNotCallable = 2_018,
GenericCompileError = 3_000,
}
Expand description
Comprehensive error codes for all compilation errors in the Slang compiler.
This enum provides unified error codes and descriptions for both parsing and semantic analysis errors. Each variant maps to a unique u16 code and has an associated description.
Error code ranges:
- 1000-1999: Parse errors (syntax and structural issues)
- 2000-2999: Semantic analysis errors (type checking, scope resolution)
- 3000-3999: Generic compile errors (not specifically categorized)
Variants§
ExpectedSemicolon = 1_001
Expected a semicolon after a statement
ExpectedClosingBrace = 1_002
Expected a closing brace
ExpectedClosingParen = 1_003
Expected a closing parenthesis
ExpectedClosingBracket = 1_004
Expected a closing bracket
ExpectedOpeningBrace = 1_005
Expected an opening brace
ExpectedOpeningParen = 1_006
Expected an opening parenthesis
ExpectedIdentifier = 1_007
Expected an identifier
ExpectedType = 1_008
Expected a type annotation
ExpectedExpression = 1_009
Expected an expression
ExpectedStatement = 1_010
Expected a statement
ExpectedParameter = 1_011
Expected a function parameter
ExpectedAssignment = 1_012
Expected an assignment operator
ExpectedComma = 1_013
Expected a comma separator
ExpectedColon = 1_014
Expected a colon
ExpectedEquals = 1_015
Expected an equals sign
ExpectedFunctionBody = 1_016
Expected a function body
ExpectedStructField = 1_017
Expected a struct field
ExpectedEof = 1_018
Expected end of file
UnexpectedToken = 1_019
Unexpected token encountered
InvalidNumberLiteral = 1_020
Invalid number literal format
InvalidStringLiteral = 1_021
Invalid string literal format
InvalidCharLiteral = 1_022
Invalid character literal format
InvalidEscapeSequence = 1_023
Invalid escape sequence in string
UnterminatedString = 1_024
Unterminated string literal
UnterminatedChar = 1_025
Unterminated character literal
MalformedComment = 1_026
Malformed comment
InvalidToken = 1_027
Invalid token in input
NestedFunction = 1_028
Nested function definitions not allowed
InvalidSyntax = 1_029
Invalid syntax in expression
UnknownType = 1_030
Encountered unknow type during parsing
ExpectedElse = 1_031
Expected ‘else’ keyword after if expression
ExpectedClosingQuote = 1_032
Expected a closing quote for a string literal
UndefinedVariable = 2_001
Variable used before being defined
VariableRedefinition = 2_002
Variable redefinition in the same scope
SymbolRedefinition = 2_003
Symbol redefinition conflict
InvalidFieldType = 2_004
Invalid type for struct field
TypeMismatch = 2_005
Type mismatch between expected and actual types
OperationTypeMismatch = 2_006
Incompatible types for operation
LogicalOperatorTypeMismatch = 2_007
Logical operator used with non-boolean types
ValueOutOfRange = 2_008
Value out of range for target type
ArgumentCountMismatch = 2_009
Function called with wrong number of arguments
ArgumentTypeMismatch = 2_010
Function argument has wrong type
ReturnOutsideFunction = 2_011
Return statement used outside function
ReturnTypeMismatch = 2_012
Return type doesn’t match function declaration
MissingReturnValue = 2_013
Missing return value for non-void function
UndefinedFunction = 2_014
Function called but not defined
InvalidUnaryOperation = 2_015
Invalid unary operation for type
AssignmentToImmutableVariable = 2_016
Assignment to immutable variable
InvalidExpression = 2_017
Expression has invalid form or context
VariableNotCallable = 2_018
Attempt to call a non-callable value (non-function)
GenericCompileError = 3_000
Generic compile error not categorized
Implementations§
§impl ErrorCode
impl ErrorCode
pub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Get a short description of the error
pub fn is_parse_error(&self) -> bool
pub fn is_parse_error(&self) -> bool
Check if this is a parse error (1000-1999 range)
pub fn is_semantic_error(&self) -> bool
pub fn is_semantic_error(&self) -> bool
Check if this is a semantic error (2000-2999 range)