This document provides a comprehensive reference for all error codes in FerrisScript. Each error includes a unique code, description, common causes, examples, and guidance on how to fix it.
FerrisScript uses structured error codes to help you quickly identify and fix issues in your code. Each error code follows the format Error[EXXX]: where XXX is a unique number in a specific range:
Compiler errors (lexical, syntax, type) include rich context with source code highlighting:
Error[E200]: Type mismatch
Expected: i32
Found: f32
|
5 | let x: i32 = 3.14;
| ^^^^ Expected 'i32', found 'f32'
Runtime errors use a simpler format:
Error[E413]: Division by zero
Error[E401]: Undefined variable: 'foo'
Errors that occur during tokenization of the source code.
Description: An invalid or unexpected character was encountered in the source code.
Common Causes:
Example:
let x = 5 @ 3; // @ is not a valid operator
Error Message:
Error[E001]: Invalid character
|
1 | let x = 5 @ 3;
| ^ Unexpected character '@' at line 1, column 11
How to Fix:
Related Codes: E002, E003
Description: A string literal was started but never closed with a closing quote.
Common Causes:
Example:
let msg = "Hello world; // Missing closing quote
Error Message:
Error[E002]: Unterminated string
|
1 | let msg = "Hello world;
| ^^^^^^^^^^^^^ String literal not closed at line 1, column 11
How to Fix:
"Hello world"See Also: E001
Related Codes: E001
Description: A number literal has an invalid format.
Common Causes:
Example:
let x = 3.14.159; // Two decimal points
Error Message:
Error[E003]: Invalid number format
|
1 | let x = 3.14.159;
| ^^^^^^^^ Invalid number format at line 1, column 9
How to Fix:
3.14159Related Codes: E001
Errors that occur during parsing of the token stream into an Abstract Syntax Tree (AST).
Description: The parser encountered a token that doesn’t fit the expected syntax.
Common Causes:
Example:
let x = 5
let y = 10; // Missing semicolon on previous line
Error Message:
Error[E100]: Unexpected token
|
2 | let y = 10;
| ^^^ Expected ';', found 'let' at line 2, column 1
How to Fix:
Related Codes: E101, E102
Description: An invalid statement or declaration was found at the top level of the program.
Common Causes:
Example:
x = 5; // Assignment at top level (use 'let' or 'let mut')
Error Message:
Error[E101]: Invalid top-level item
|
1 | x = 5;
| ^ Expected function or global variable declaration at line 1, column 1
How to Fix:
let or let mut for global variablesfn keyword for function declarationsRelated Codes: E100, E102
Description: The parser expected an expression but found something else.
Common Causes:
Example:
let x = 5 + ; // Missing right operand
Error Message:
Error[E102]: Expected expression
|
1 | let x = 5 + ;
| ^ Expected expression, found ';' at line 1, column 13
How to Fix:
Related Codes: E100, E103
Description: A field name was expected in field access or object construction but wasn’t found.
Common Causes:
Example:
let val = vector2.; // Missing field name
Error Message:
Error[E103]: Expected field name
|
1 | let val = vector2.;
| ^ Expected field name after '.', found ';' at line 1, column 19
How to Fix:
vector2.x or vector2.yRelated Codes: E102, E215
Description: The parser expected a statement but found something else.
Common Causes:
Example:
fn test() {
+ // Expression without context
}
Error Message:
Error[E104]: Expected statement
|
2 | +
| ^ Expected statement, found '+' at line 2, column 5
How to Fix:
Related Codes: E100, E102
Description: A type annotation was expected but not provided or invalid.
Common Causes:
Example:
fn add(a: , b: i32) -> i32 { // Missing type for 'a'
return a + b;
}
Error Message:
Error[E105]: Expected type
|
1 | fn add(a: , b: i32) -> i32 {
| ^ Expected type annotation, found ',' at line 1, column 11
How to Fix:
a: i32i32, f32, bool, String, Vector2Related Codes: E110, E218
Description: An identifier (name) was expected but not found.
Common Causes:
Example:
let = 5; // Missing variable name
Error Message:
Error[E106]: Expected identifier
|
1 | let = 5;
| ^ Expected identifier, found '=' at line 1, column 5
How to Fix:
Related Codes: E109
Description: A code block (enclosed in curly braces) was expected but not found.
Common Causes:
Example:
fn test()
return 5; // Missing braces around function body
Error Message:
Error[E107]: Expected block
|
2 | return 5;
| ^^^^^^ Expected '{', found 'return' at line 2, column 5
How to Fix:
fn test() { return 5; }Related Codes: E100
Description: A function parameter was expected but not properly formed.
Common Causes:
Example:
fn add(a: i32, ) -> i32 { // Trailing comma without parameter
return a + 1;
}
Error Message:
Error[E108]: Expected parameter
|
1 | fn add(a: i32, ) -> i32 {
| ^ Expected parameter, found ')' at line 1, column 16
How to Fix:
name: typeRelated Codes: E111
Description: An identifier name is invalid or uses a reserved keyword.
Common Causes:
Example:
let fn = 5; // 'fn' is a keyword
Error Message:
Error[E109]: Invalid identifier
|
1 | let fn = 5;
| ^^ 'fn' is a reserved keyword and cannot be used as an identifier at line 1, column 5
How to Fix:
fn, let, mut, if, else, while, return, true, falseRelated Codes: E106
Description: An invalid or unknown type was specified.
Common Causes:
Example:
let x: int = 5; // 'int' is not valid, should be 'i32'
Error Message:
Error[E110]: Invalid type
|
1 | let x: int = 5;
| ^^^ Unknown type 'int' at line 1, column 8
How to Fix:
i32, f32, bool, String, Vector2Related Codes: E105, E218
Description: A function parameter has invalid syntax or structure.
Common Causes:
Example:
fn add(a i32, b: i32) -> i32 { // Missing colon
return a + b;
}
Error Message:
Error[E111]: Invalid parameter
|
1 | fn add(a i32, b: i32) -> i32 {
| ^^^^^ Expected ':' after parameter name at line 1, column 8
How to Fix:
name: typeRelated Codes: E108
Description: The return type of a function has invalid syntax.
Common Causes:
->Example:
fn test() -> { // Missing return type
return 5;
}
Error Message:
Error[E112]: Invalid return type
|
1 | fn test() -> {
| ^ Expected return type after '->', found '{' at line 1, column 14
How to Fix:
-> i32-> for void functionsRelated Codes: E110
Description: An invalid or unexpected operator was encountered.
Common Causes:
Example:
let x = 5 ** 2; // '**' is not a valid operator
Error Message:
Error[E113]: Invalid operator
|
1 | let x = 5 ** 2;
| ^^ Unsupported or invalid operator at line 1, column 11
How to Fix:
+, -, *, /, ==, !=, <, <=, >, >=, &&, ||, !Related Codes: E100
Errors that occur during type checking of the AST.
Description: An expression or value has a type that doesn’t match what’s expected.
Common Causes:
Example:
let x: i32 = 3.14; // Assigning f32 to i32 variable
Error Message:
Error[E200]: Type mismatch
Expected: i32
Found: f32
|
1 | let x: i32 = 3.14;
| ^^^^ Expected 'i32', found 'f32'
How to Fix:
let x: f32 = 3.14;Related Codes: E219, E205
Description: A variable is used before it’s declared or is not in scope.
Common Causes:
Example:
fn test() {
let x = y + 5; // 'y' is not defined
}
Error Message:
Error[E201]: Undefined variable 'y'
|
2 | let x = y + 5;
| ^ Variable must be declared before use
How to Fix:
let y = 10;See Also: E401 (runtime version)
Related Codes: E401
Description: A function is called but hasn’t been defined.
Common Causes:
Example:
fn main() {
let x = add(5, 3); // 'add' function not defined
}
Error Message:
Error[E202]: Undefined function 'add'
|
2 | let x = add(5, 3);
| ^^^ Function not found
How to Fix:
See Also: E415 (runtime version), E402
Related Codes: E415
Description: A function is called with the wrong number of arguments.
Common Causes:
Example:
fn add(a: i32, b: i32) -> i32 {
return a + b;
}
fn main() {
let x = add(5); // Missing second argument
}
Error Message:
Error[E204]: Wrong number of arguments
Function 'add' expects 2 arguments, got 1
|
6 | let x = add(5);
| ^^^^^^ Expected 2 arguments
How to Fix:
add(5, 3)Related Codes: E416
Description: An argument passed to a function has the wrong type.
Common Causes:
Example:
fn greet(name: String) {
print(name);
}
fn main() {
greet(42); // Passing i32 instead of String
}
Error Message:
Error[E205]: Incorrect argument type
Parameter 'name' expects String, got i32
|
6 | greet(42);
| ^^ Expected 'String', found 'i32'
How to Fix:
greet("Alice")Related Codes: E200
Description: Attempting to access a field on a value that doesn’t support field access.
Common Causes:
Example:
let x: i32 = 42;
let y = x.field; // Can't access field on i32
Error Message:
Error[E209]: Invalid field access
Cannot access field 'field' on i32
|
2 | let y = x.field;
| ^ i32 does not have fields
How to Fix:
Related Codes: E215, E408
Description: A condition in an if statement or while loop must be a boolean expression.
Common Causes:
Example:
let x = 5;
if x { // 'x' is i32, not bool
print("true");
}
Error Message:
Error[E211]: Condition must be boolean
Condition in if/while must be type bool, got i32
|
2 | if x {
| ^ Expected bool, found i32
How to Fix:
if x > 0 {if x == 5 {Related Codes: E200
Description: A binary operation has operands of incompatible types.
Common Causes:
Example:
let x = "hello" + 42; // Can't add String and i32
Error Message:
Error[E212]: Binary operation type error
Cannot apply '+' to String and i32
|
1 | let x = "hello" + 42;
| ^^^^^^^^^^^^^ Incompatible types
How to Fix:
Related Codes: E200
Description: A unary operation is applied to an incompatible type.
Common Causes:
- on non-numeric type! on non-boolean typeExample:
let x = -"hello"; // Can't negate a string
Error Message:
Error[E213]: Unary operation type error
Cannot apply '-' to String
|
1 | let x = -"hello";
| ^^^^^^^^ '-' requires numeric type
How to Fix:
- works on i32 and f32! works on boolRelated Codes: E414
Description: Attempting to access a field that doesn’t exist on the object.
Common Causes:
Example:
let vec = Vector2 { x: 1.0, y: 2.0 };
let z = vec.z; // Vector2 doesn't have 'z' field
Error Message:
Error[E215]: Field not found
Vector2 has no field 'z'
|
2 | let z = vec.z;
| ^ Valid fields are: x, y
How to Fix:
x and y are validSee Also: E407 (runtime version), E103, E209
Related Codes: E407, E103
Description: A type cannot be inferred and must be explicitly annotated.
Common Causes:
Example:
let x; // No type or initial value
Error Message:
Error[E218]: Type annotation required
Cannot infer type for 'x'
|
1 | let x;
| ^ Provide type annotation or initial value
How to Fix:
let x: i32;let x = 0;let x: i32 = 0;Related Codes: E105, E110
Description: Cannot assign a value to a variable due to type incompatibility.
Common Causes:
Example:
let mut x = 5;
x = "hello"; // Can't assign String to i32 variable
Error Message:
Error[E219]: Incompatible types in assignment
Cannot assign String to variable of type i32
|
2 | x = "hello";
| ^^^^^^^ Expected i32, found String
How to Fix:
Related Codes: E200
Errors related to signal declarations and usage.
Description: A signal with the same name has already been declared in the current scope.
Common Causes:
Example:
signal health_changed(old: i32, new: i32);
signal health_changed(value: i32); // Error: signal already defined
Error Message:
Error[E301]: Signal already defined
Signal 'health_changed' is already defined
|
2 | signal health_changed(value: i32);
| ^^^^^^^^^^^^^^ Signal already declared at line 1
How to Fix:
Related Codes: E302, E303, E304
Description: Attempting to emit a signal that has not been declared.
Common Causes:
Example:
fn take_damage() {
emit_signal("health_change", 100, 75); // Typo: should be "health_changed"
}
Error Message:
Error[E302]: Signal not defined
Signal 'health_change' is not defined
|
2 | emit_signal("health_change", 100, 75);
| ^^^^^^^^^^^^^^^ Signal not declared
|
= help: Did you mean 'health_changed'?
How to Fix:
Related Codes: E301, E303, E304
Description: The number of arguments provided to emit_signal doesn’t match the signal’s declared parameter count.
Common Causes:
Example:
signal health_changed(old: i32, new: i32);
fn take_damage() {
emit_signal("health_changed", 75); // Missing 'old' parameter
}
Error Message:
Error[E303]: Signal parameter count mismatch
Signal 'health_changed' expects 2 parameters, but 1 provided
|
4 | emit_signal("health_changed", 75);
| ^^^^^^^^^^^^^^^^^^^^^^ Expected 2 arguments
How to Fix:
Related Codes: E301, E302, E304
Description: An argument provided to emit_signal doesn’t match the expected parameter type.
Common Causes:
Example:
signal score_updated(score: i32);
fn add_score() {
emit_signal("score_updated", "100"); // String instead of i32
}
Error Message:
Error[E304]: Signal parameter type mismatch
Signal 'score_updated' parameter 1 expects i32, but String provided
|
4 | emit_signal("score_updated", "100");
| ^^^^^ Expected i32, found String
How to Fix:
Related Codes: E301, E302, E303, E200
Errors that occur during program execution.
Description: Attempting to assign to a variable that wasn’t declared as mutable.
Common Causes:
mut keyword in variable declarationExample:
let x = 5;
x = 10; // 'x' is immutable
Error Message:
Error[E400]: Cannot assign to immutable variable 'x'
How to Fix:
let mut x = 5;See Also: E405
Related Codes: E405
Description: Runtime reference to a variable that doesn’t exist.
Common Causes:
Example:
fn test() {
print(undefined_var); // Variable not defined
}
Error Message:
Error[E401]: Undefined variable: undefined_var
How to Fix:
See Also: E201 (compile-time version)
Related Codes: E201
Description: Calling a built-in function that doesn’t exist.
Common Causes:
Example:
fn main() {
println("Hello"); // 'println' doesn't exist, use 'print'
}
Error Message:
Error[E402]: Unknown built-in function: println
How to Fix:
printRelated Codes: E202, E415
Description: Attempting to assign to something that can’t be assigned to.
Common Causes:
Example:
fn test() {
5 = x; // Can't assign to literal
}
Error Message:
Error[E403]: Invalid assignment target
How to Fix:
Related Codes: None
Description: Attempting to set a property on self when no property setter is registered.
Common Causes:
Example:
fn _ready() {
self.position = Vector2 { x: 0.0, y: 0.0 };
}
Error Message:
Error[E404]: Cannot set self properties: no property setter registered
How to Fix:
Related Codes: E410, E417
Description: Attempting to modify a field of an immutable variable.
Common Causes:
mut keywordExample:
let vec = Vector2 { x: 1.0, y: 2.0 };
vec.x = 5.0; // 'vec' is immutable
Error Message:
Error[E405]: Cannot assign to field of immutable variable 'vec'
How to Fix:
let mut vec = ...Related Codes: E400
Description: Attempting to assign an incompatible value to a Vector2 field.
Common Causes:
Example:
let mut vec = Vector2 { x: 1.0, y: 2.0 };
vec.x = "hello"; // Can't assign String to float field
Error Message:
Error[E406]: Cannot assign String to Vector2.x
How to Fix:
vec.x = 5.0;Related Codes: E200, E407
Description: Attempting to access a field that doesn’t exist on Vector2.
Common Causes:
Example:
let vec = Vector2 { x: 1.0, y: 2.0 };
let z = vec.z; // Vector2 only has x and y
Error Message:
Error[E407]: Vector2 has no field 'z'
How to Fix:
x or ySee Also: E215 (compile-time version), E406
Related Codes: E215
Description: Attempting to access a field on a value that doesn’t support fields.
Common Causes:
Example:
let x = 42;
let y = x.field; // i32 doesn't have fields
Error Message:
Error[E408]: Cannot access field 'field' on i32
How to Fix:
Related Codes: E209
Description: Expected a Vector2 property but got a different type.
Common Causes:
Example:
fn _process(delta: f32) {
self.name.x = 5.0; // 'name' is String, not Vector2
}
Error Message:
Error[E409]: Property 'name' is not a Vector2
How to Fix:
Related Codes: E200
Description: Attempting to get a property from self when no property getter is registered.
Common Causes:
Example:
fn test() {
let pos = self.position;
}
Error Message:
Error[E410]: Cannot get self properties: no property getter registered
How to Fix:
Related Codes: E404, E417
Description: Nested field assignments on regular variables are not yet supported.
Common Causes:
Example:
let mut obj = ...;
obj.field.subfield = value; // Not yet supported
Error Message:
Error[E411]: Nested field assignment on regular variables not yet implemented
How to Fix:
Related Codes: E412
Description: Complex field assignment patterns are not yet supported.
Common Causes:
Example:
complex_expression().field = value;
Error Message:
Error[E412]: Complex field assignment not yet implemented
How to Fix:
Related Codes: E411
Description: Attempting to divide by zero.
Common Causes:
Example:
let x = 10 / 0; // Division by zero
Error Message:
Error[E413]: Division by zero
How to Fix:
Related Codes: None
Description: Attempting to use unary negation on a non-numeric type.
Common Causes:
- on String, bool, or other non-numericExample:
let x = -"hello"; // Can't negate String
Error Message:
Error[E414]: Cannot negate non-numeric value
How to Fix:
Related Codes: E213
Description: Runtime call to a function that doesn’t exist.
Common Causes:
Example:
fn main() {
call_function("undefined_func", []);
}
Error Message:
Error[E415]: Undefined function: undefined_func
How to Fix:
Related Codes: E202, E402
Description: Runtime function call with wrong number of arguments.
Common Causes:
Example:
fn add(a: i32, b: i32) -> i32 { return a + b; }
fn main() {
let result = add(5, 10, 15); // Too many arguments
}
Error Message:
Error[E416]: Function 'add' expects 2 arguments, got 3
How to Fix:
Related Codes: E204
Description: Attempting to access self properties when no property getter is registered.
Common Causes:
Example:
fn test() {
let pos = self.position;
}
Error Message:
Error[E417]: Cannot access self properties: no property getter registered
How to Fix:
Related Codes: E404, E410
Description: Assignment used as an expression in invalid context.
Common Causes:
Example:
let x = (y = 5); // Assignment as expression
Error Message:
Error[E418]: Assignment expressions should be statements
How to Fix:
Related Codes: None
Description: emit_signal was called without providing a signal name as the first argument.
Common Causes:
Example:
fn trigger_event() {
emit_signal(); // Missing signal name
}
Error Message:
Error[E501]: emit_signal requires at least a signal name
How to Fix:
Correct Usage:
emit_signal("player_died");
emit_signal("health_changed", 100, 75);
Related Codes: E502, E302, E303
Description: The first argument to emit_signal must be a string literal containing the signal name.
Common Causes:
Example:
fn trigger_event() {
emit_signal(123, 456); // First argument must be string
}
Error Message:
Error[E502]: emit_signal first argument must be a string
How to Fix:
Correct Usage:
emit_signal("score_updated", 100);
emit_signal("player_died");
Related Codes: E501, E302
If you encounter an error code not listed here or need additional help:
Found an error code that’s unclear or missing information? Please submit a PR to improve this documentation!