Adesh Diagnostic Error Codes Index
This document provides a canonical, comprehensive index of all diagnostic codes emitted by the Adesh compiler, linker, and runtime.
Adesh adopts a strict, two-tier error-code design:
- Rust-Compatible Codes (
E0001–E9999): Used exclusively when the semantic condition and developer remediation directly correspond to an equivalent Rust compiler error code. - Adesh-Specific Codes (
AD0001–AD9999): Dedicated to Adesh-specific language semantics, novel execution models, embedded modes, and binary packaging. - Linker Codes (
LNK001–LNK016): Dedicated to object-file resolution, relocation, section mapping, and final executable layout.
To inspect any error code directly from the terminal, run:
adesh --explain <CODE>
# Example:
adesh --explain E0308
adesh --explain AD0001
adesh --explain list
Table of Contents
- Rust-Compatible Error Codes
- E0106: Missing lifetime specifier
- E0277: Trait or interface bound not satisfied
- E0308: Mismatched types
- E0381: Use of possibly uninitialized variable
- E0382: Use of moved value
- E0384: Reassignment to immutable variable
- E0416: Identifier bound more than once in pattern
- E0425: Cannot find value or variable in scope
- E0428: Duplicate identifier defined in same scope
- E0499: Cannot borrow variable as mutable more than once at a time
- E0502: Cannot borrow variable as mutable while already borrowed as immutable
- E0505: Cannot move out of variable because it is borrowed
- E0506: Cannot assign to variable because it is borrowed
- E0515: Cannot return reference to local variable or temporary
- E0597: Borrowed value does not live long enough
- E0631: Closure or function argument type mismatch in higher-order call
- E0733: Async recursion requires heap indirection
- Adesh-Specific Diagnostic Codes
- AD0001: Unrecognized character or malformed token
- AD0002: Syntax error or unrecoverable parse sequence
- AD0003: Await expression outside async function context
- AD0004: Embedded mode heap allocation prohibited
- AD0005: Corrupt or invalid object-file format / ADOB payload
- AD0006: Unsupported relocation type or target relocation overflow
- AD0007: Unhandled runtime trap or virtual machine fault
- Adesh Native Linker Codes
Rust-Compatible Error Codes
E0106 — Missing lifetime specifier
- Severity: Error
- Phase: TypeCheck / Ownership
- Rust Mapping Justification: Identical to
rustc E0106. Occurs when a function returns a reference or a struct contains a reference without specifying its lifetime association. - Erroneous Code:
fn first(list: &[int]) -> &int {return &list[0];}
- Corrected Code:
fn first<'a>(list: &'a [int]) -> &'a int {return &list[0];}
- Common Causes:
- Returning a borrowed reference from a function taking multiple reference arguments without lifetime annotations.
- Defining a struct with borrowed fields without lifetime parameters.
- Suggested Fixes:
- Add explicit lifetime annotations matching the input parameters to the return type.
- Return an owned value rather than a reference.
E0277 — Trait or interface bound not satisfied
- Severity: Error
- Phase: TypeCheck
- Rust Mapping Justification: Identical to
rustc E0277. Triggered when a type parameter does not satisfy the trait, interface, or protocol bound demanded by a function or struct definition. - Erroneous Code:
fn display<T: Printable>(item: T) {item.print();}let s = Socket::new();display(s); // Socket does not implement Printable
- Corrected Code:
impl Printable for Socket {fn print(&self) { println!("Socket"); }}display(s);
- Common Causes:
- Passing a concrete type that lacks an required
implblock for the requested interface.
- Passing a concrete type that lacks an required
- Suggested Fixes:
- Implement the missing interface on the type.
- Relax the generic constraint on the target function.
E0308 — Mismatched types
- Severity: Error
- Phase: TypeCheck
- Rust Mapping Justification: Direct equivalent to
rustc E0308. An expression had a type that was incompatible with the type expected by its surrounding context. - Erroneous Code:
let count: i32 = "seven";
- Corrected Code:
let count: i32 = 7;// orlet count_str: string = "seven";
- Common Causes:
- Providing a string where an integer is expected.
- Returning a value that does not match the declared function return type.
- Omitting an explicit cast or type conversion.
- Suggested Fixes:
- Provide a value matching the declared type.
- Change the type annotation to match the assigned value.
- Use an explicit conversion function or constructor.
E0381 — Use of possibly uninitialized variable
- Severity: Error
- Phase: Ownership / Semantic
- Rust Mapping Justification: Direct equivalent to
rustc E0381. A variable is evaluated in an expression before it has been guaranteed an initial value across all control flow branches. - Erroneous Code:
let total: int;if condition {total = 10;}println("{}", total); // uninitialized if !condition
- Corrected Code:
let total: int = 0;if condition {total = 10;}println("{}", total);
- Common Causes:
- Declaring a variable without a default assignment and missing an
elsebranch.
- Declaring a variable without a default assignment and missing an
- Suggested Fixes:
- Assign a default initial value at the declaration site.
- Ensure all conditional branches initialize the variable before read access.
E0382 — Use of moved value
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0382. A variable whose type does not implementCopywas moved and subsequently accessed. - Erroneous Code:
let msg = Buffer::from("hello");consume(msg);println("{}", msg); // error[E0382]: use of moved value `msg`
- Corrected Code:
let msg = Buffer::from("hello");consume(msg.clone());println("{}", msg);// or pass by reference:inspect(&msg);
- Common Causes:
- Passing an owned heap resource into a function by value.
- Accessing a variable in a loop after moving it in the first iteration.
- Suggested Fixes:
- Pass the value by reference (
&msg) if ownership transfer is unnecessary. - Explicitly clone or duplicate the value with
.clone().
- Pass the value by reference (
E0384 — Reassignment to immutable variable
- Severity: Error
- Phase: Semantic / Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0384. An immutable variable was reassigned a new value. - Erroneous Code:
let count = 10;count = 20; // error[E0384]: cannot assign twice to immutable variable
- Corrected Code:
let mut count = 10;count = 20;
- Common Causes:
- Omitting the
mutkeyword in the variable declaration.
- Omitting the
- Suggested Fixes:
- Add
mutto theletbinding:let mut name = value;.
- Add
E0416 — Identifier bound more than once in pattern
- Severity: Error
- Phase: Parser / Semantic
- Rust Mapping Justification: Direct equivalent to
rustc E0416. The same variable name is bound multiple times within a single pattern or match arm. - Erroneous Code:
match pair {(x, x) => println("equal: {}", x),}
- Corrected Code:
match pair {(x, y) if x == y => println("equal: {}", x),}
- Common Causes:
- Attempting to enforce equality using duplicate identifiers in pattern matching.
- Suggested Fixes:
- Use distinct identifier names in the pattern and add a pattern guard
if a == b.
- Use distinct identifier names in the pattern and add a pattern guard
E0425 — Cannot find value or variable in scope
- Severity: Error
- Phase: Semantic
- Rust Mapping Justification: Direct equivalent to
rustc E0425. An identifier was referenced that has not been declared or imported in the current scope. - Erroneous Code:
fn compute() {return unknown_metric + 10;}
- Corrected Code:
fn compute() {let unknown_metric = 42;return unknown_metric + 10;}
- Common Causes:
- Typo in the variable or function name.
- Missing
importstatement for a module or dependency. - Accessing a local variable outside its declaring block.
- Suggested Fixes:
- Check the spelling of the identifier.
- Import the module exporting the name.
- Declare the variable with
letbefore use.
E0428 — Duplicate identifier defined in same scope
- Severity: Error
- Phase: Semantic
- Rust Mapping Justification: Direct equivalent to
rustc E0428. A type, function, constant, or variable has already been defined with the same name in this scope. - Erroneous Code:
fn calculate() -> int { return 1; }fn calculate() -> int { return 2; }
- Corrected Code:
fn calculate_primary() -> int { return 1; }fn calculate_secondary() -> int { return 2; }
- Common Causes:
- Declaring two functions, structs, or constants with identical names in the same module.
- Suggested Fixes:
- Rename one of the definitions.
- Place related definitions in separate modules.
E0499 — Cannot borrow variable as mutable more than once at a time
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0499. Multiple concurrent active mutable borrows exist for the same value. - Erroneous Code:
let mut buffer = Buffer::new();let ref1 = &mut buffer;let ref2 = &mut buffer; // error[E0499]ref1.write("a");
- Corrected Code:
let mut buffer = Buffer::new();{let ref1 = &mut buffer;ref1.write("a");}let ref2 = &mut buffer;ref2.write("b");
- Common Causes:
- Retaining a mutable reference while attempting a second mutable borrow in the same scope.
- Suggested Fixes:
- Limit the lifetime of the first borrow with curly braces
{}or complete modifications sequentially.
- Limit the lifetime of the first borrow with curly braces
E0502 — Cannot borrow variable as mutable while already borrowed as immutable
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0502. A value cannot be borrowed mutably while immutable references to it are still active. - Erroneous Code:
let mut data = vec![1, 2, 3];let first = &data[0];data.push(4); // error[E0502]: cannot borrow `data` as mutable because it is also borrowed as immutableprintln("{}", first);
- Corrected Code:
let mut data = vec![1, 2, 3];let first_val = data[0]; // copy the valuedata.push(4);println("{}", first_val);
- Common Causes:
- Mutating a collection while holding an iterator or element reference.
- Suggested Fixes:
- Clone or copy scalar elements before modifying the underlying collection.
- Finish using immutable references before calling mutating methods.
E0505 — Cannot move out of variable because it is borrowed
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0505. A value was moved while an active borrow of that value exists. - Erroneous Code:
let data = DataBuffer::new();let r = &data;consume(data); // error[E0505]: cannot move out of `data` because it is borrowedr.read();
- Corrected Code:
let data = DataBuffer::new();let r = &data;r.read();consume(data); // move after borrow ends
- Common Causes:
- Moving ownership before completing reads via an existing reference.
- Suggested Fixes:
- Reorder statements so ownership transfer happens after the last reference read.
E0506 — Cannot assign to variable because it is borrowed
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0506. Reassigning or mutating a variable is prohibited while an active borrow is outstanding. - Erroneous Code:
let mut x = 10;let r = &x;x = 20; // error[E0506]println("{}", r);
- Corrected Code:
let mut x = 10;let r = &x;println("{}", r);x = 20;
- Common Causes:
- Overwriting a variable whose address is held by an active reference.
- Suggested Fixes:
- Complete all uses of the reference before overwriting the variable.
E0515 — Cannot return reference to local variable or temporary
- Severity: Error
- Phase: Ownership / Lowering
- Rust Mapping Justification: Direct equivalent to
rustc E0515. Returning a reference to data allocated on the current stack frame would create a dangling pointer. - Erroneous Code:
fn create_ref() -> &String {let s = String::from("local");return &s; // error[E0515]}
- Corrected Code:
fn create_ref() -> String {let s = String::from("local");return s; // transfer ownership}
- Common Causes:
- Returning
&local_varfrom a function.
- Returning
- Suggested Fixes:
- Return the owned value by value instead of returning a reference.
- Store the data in a caller-supplied buffer or arena.
E0597 — Borrowed value does not live long enough
- Severity: Error
- Phase: Ownership
- Rust Mapping Justification: Direct equivalent to
rustc E0597. A reference outlives the scope of the data it points to. - Erroneous Code:
let r: ∫{let x = 42;r = &x;} // x is dropped hereprintln("{}", r); // error[E0597]
- Corrected Code:
let x = 42;let r = &x;println("{}", r);
- Common Causes:
- Assigning a reference to a variable declared in an outer scope from an inner block.
- Suggested Fixes:
- Declare the borrowed value in the outer scope.
E0631 — Closure or function argument type mismatch in higher-order call
- Severity: Error
- Phase: TypeCheck
- Rust Mapping Justification: Direct equivalent to
rustc E0631. A closure or function passed to a higher-order function expects different parameter types or return types than the signature required. - Erroneous Code:
fn process(items: &[int], f: fn(string) -> int) { ... }fn square(x: int) -> int { return x * x; }process(nums, square); // error[E0631]
- Corrected Code:
fn process(items: &[int], f: fn(int) -> int) { ... }process(nums, square);
- Common Causes:
- Incorrect parameter type in callback or closure.
- Suggested Fixes:
- Update callback signature to match the expected parameter types.
E0733 — Async recursion requires heap indirection
- Severity: Error
- Phase: TypeCheck / Lowering
- Rust Mapping Justification: Direct equivalent to
rustc E0733. Anasync fnrecursively calls itself without heap indirection (Boxor dynamic promise), causing an infinite state machine size. - Erroneous Code:
async fn countdown(n: int) {if n > 0 { countdown(n - 1).await; }}
- Corrected Code:
fn countdown(n: int) -> BoxFuture<()> {BoxFuture::new(async move {if n > 0 { countdown(n - 1).await; }})}
- Common Causes:
- Direct recursion in an async routine.
- Suggested Fixes:
- Wrap recursive future instantiation in heap allocation or use an iterative loop.
Adesh-Specific Diagnostic Codes
AD0001 — Unrecognized character or malformed token
- Severity: Error
- Phase: Lexer
- Erroneous Code:
let x = @#$%;let s = "\xZZ";
- Corrected Code:
let x = 42;let s = "\x7F";
- Common Causes:
- Pasting non-ASCII characters or unsupported operators.
- Invalid escape sequence in string literal.
- Suggested Fixes:
- Remove unexpected symbols or replace invalid escape sequences.
AD0002 — Syntax error or unrecoverable parse sequence
- Severity: Error
- Phase: Parser
- Erroneous Code:
fn test() {let a: int = ;}
- Corrected Code:
fn test() {let a: int = 10;}
- Common Causes:
- Missing expression, mismatched parentheses
(), or unclosed curly braces{}.
- Missing expression, mismatched parentheses
- Suggested Fixes:
- Check syntax near the caret; provide the expected expression or close open delimiters.
AD0003 — Await expression outside async function context
- Severity: Error
- Phase: TypeCheck / Semantic
- Erroneous Code:
fn calculate() {let res = fetch_data().await;}
- Corrected Code:
async fn calculate() {let res = fetch_data().await;}
- Common Causes:
- Calling
.awaitinside a synchronous function.
- Calling
- Suggested Fixes:
- Mark the enclosing function with
async fn. - Use
block_on(fetch_data())if executing synchronously from an entry point.
- Mark the enclosing function with
AD0004 — Embedded mode heap allocation prohibited
- Severity: Error
- Phase: Ownership / Semantic
- Erroneous Code:
// Compiled with --embeddedlet buffer = alloc(1024);
- Corrected Code:
let mut buffer: [u8; 1024] = [0; 1024]; // stack allocation// or use region arena
- Common Causes:
- Invoking global heap allocator
alloc()or dynamic heap constructs when compiling for bare-metal embedded targets.
- Invoking global heap allocator
- Suggested Fixes:
- Use fixed-size stack arrays, static memory buffers, or region arena allocations.
AD0005 — Corrupt or invalid object-file format / ADOB payload
- Severity: Error
- Phase: Linker / Object
- Common Causes:
- Truncated
.oor.adobfile. - Incompatible endianness or invalid magic header bytes.
- Truncated
- Suggested Fixes:
- Recompile intermediate object files with the matching version of the Adesh toolchain.
AD0006 — Unsupported relocation type or target relocation overflow
- Severity: Error
- Phase: Linker
- Common Causes:
- Absolute 32-bit relocation referencing an address exceeding 4GB range in a 64-bit target.
- Target architecture does not support the relocation requested.
- Suggested Fixes:
- Compile with position-independent code enabled (
-fPIC/--pie). - Verify linking matches the target architecture triple.
- Compile with position-independent code enabled (
AD0007 — Unhandled runtime trap or virtual machine fault
- Severity: Error
- Phase: Runtime
- Erroneous Code:
let zero = 0;let res = 10 / zero;
- Common Causes:
- Integer division by zero, out-of-bounds array indexing, or explicit
panic!().
- Integer division by zero, out-of-bounds array indexing, or explicit
- Suggested Fixes:
- Validate divisors before division operations.
- Check array bounds using
.len()or safe slice access methods.
Adesh Native Linker Codes
The native linker (adesh-linker) produces structured LNK### errors for binary generation:
| Code | Title | Description |
|---|---|---|
LNK001 | UndefinedSymbol | Undefined symbol referenced by an input object. |
LNK002 | DuplicateSymbol | Duplicate strong symbol definition found across objects. |
LNK003 | ArchitectureMismatch | Incompatible architecture between object files and target. |
LNK004 | FormatMismatch | Object file format does not match output binary format (ELF/PE/Mach-O). |
LNK005 | RelocationOverflow | Calculated address offset overflows field bit-width. |
LNK006 | InvalidObject | Malformed or corrupt object header/payload. |
LNK007 | AbiMismatch | Incompatible calling convention or ABI between modules. |
LNK008 | UnsupportedRelocation | Relocation type not implemented for the current CPU arch. |
LNK009 | InvalidSection | Invalid section alignment, flags, or configuration. |
LNK010 | InvalidTarget | Target triple unrecognized or unsupported. |
LNK011 | EntryPointNotFound | main or specified entry point symbol not found. |
LNK012 | InvalidArchive | Static library .a member or symbol table corrupted. |
LNK013 | SecurityViolation | Layout violates memory protection invariants (e.g. W^X). |
LNK014 | MetadataMismatch | Incompatible .adesh.meta binary metadata. |
LNK015 | IoError | Failed to read input or write executable binary. |
LNK016 | MemoryExhausted | Target memory region or address space exhausted. |