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

pub fn code(&self) -> u16

Get the numeric error code as a u16

pub fn description(&self) -> &'static str

Get a short description of the error

pub fn is_parse_error(&self) -> bool

Check if this is a parse error (1000-1999 range)

pub fn is_semantic_error(&self) -> bool

Check if this is a semantic error (2000-2999 range)

Trait Implementations§

§

impl Clone for ErrorCode

§

fn clone(&self) -> ErrorCode

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for ErrorCode

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Display for ErrorCode

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Hash for ErrorCode

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for ErrorCode

§

fn eq(&self, other: &ErrorCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Copy for ErrorCode

§

impl Eq for ErrorCode

§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.