Files
aji/docs/reference/error-codes.md
T

12 KiB

Error Code Registry

Draft registry. Codes are stable once released in a tagged compiler version.

E0xxx — AIR text and module

Code Kind Meaning
E0001 parse.unexpected_token Token not allowed by the text AIR grammar here
E0002 parse.invalid_literal Literal malformed or not representable in its type
E0003 parse.duplicate_name Function, type, block, field or variant name defined twice
E0004 parse.unknown_name Unknown opcode, type, function, field or variant
E0005 module.unsupported_version AIR format or language version not implemented
E0006 module.unsupported_feature Feature unknown, unsupported, undeclared or dependency-incomplete, or reserved type used; field reason (reference/air-features.md)

E1xxx — Types and values

Code Kind Meaning
E1001 type.mismatch Operand/result type mismatch
E1002 type.invalid_cast Cast not permitted by safe semantics
E1003 type.recursive Aggregate type contains itself by value
E1010 init.read_uninitialized Read from uninitialized storage

E2xxx — Memory and ownership

Code Kind Meaning
E2001 ownership.use_after_move Value used after ownership transfer
E2002 ownership.double_consume Linear value consumed twice
E2101 borrow.mutable_alias Overlapping exclusive/shared borrow violation; related definition when conflicts_with is identified (spec 10 §2)
E2102 borrow.outlives_owner Borrow may outlive backing storage
E2103 memory.out_of_bounds Access not proven in bounds
E2104 memory.region_generation Reference belongs to invalidated region generation; related definition when conflicts_with is identified (spec 10 §2)
E2110 island.escape Island-internal reference escapes island
E2105 borrow.not_ended Owned borrow live at ret, or borrow state differs between edges into a block
E2106 borrow.use_after_end Borrow used or ended after it was ended
E2107 borrow.not_owned Lent (parameter) borrow ended by the callee
E2108 borrow.escapes_frame Borrow derived from frame storage returned from its function
E2111 island.foreign_mutable_edge Island graph points to forbidden foreign mutable storage

E3xxx — Resources/capabilities/effects

Code Kind Meaning
E3001 resource.use_after_consume Closed/joined/released resource reused
E3002 resource.leak Linear resource has no terminal consumption path
E3101 effect.undeclared Callee effect absent from caller contract
E3201 capability.missing Required authority unavailable
E3202 capability.widen Attempt to widen delegated authority; unsupported narrowing forms identify capability_kind

E4xxx — Concurrency

Code Kind Meaning
E4001 concurrency.not_send Non-Send value moved to migratable task/thread
E4002 concurrency.not_share Non-Share value concurrently shared
E4101 concurrency.possible_data_race Conflicting ordinary access not ordered/synchronized
E4201 atomic.invalid_order Memory ordering invalid for atomic operation
E4202 atomic.ordinary_access Atomic cell accessed by an ordinary load
E4203 atomic.unsupported_width Atomic width not implemented lock-free by the target
E4301 task.live_child_escape Scope exits with live child task
E4302 task.borrow_escape Child task borrow can outlive parent storage; related spawn when task is identified (spec 10 §2)
E4303 io.buffer_in_flight Buffer accessed while async operation owns/borrows it
E4304 sync.wait_while_locked Suspending operation, spawn, or call of a waiting/spawning function while a lock guard is live
E4305 task.shield_order Shield ended while a more inner shield is live

E5xxx — AIR/verifier

Code Kind Meaning
E5001 air.invalid_ssa SSA definition/dominance failure
E5002 air.invalid_cfg Invalid block/terminator structure
E5101 verifier.resource_limit Deterministic verifier resource limit exceeded

E6xxx — Unsafe/ABI

Code Kind Meaning
E6001 unsafe.required Operation requires explicit unsafe boundary; field reason: outside_boundary, trusted_declares_unsafe
E6101 abi.unaligned_reference Normal reference requested from insufficiently aligned storage

E7xxx — Source language .aji (spec 15 §10)

Only problems that exist because of the frontend. Everything the verifier decides keeps its AIR code, reported at the source location.

Code Kind Meaning
E7001 source.syntax Malformed .aji source
E7002 source.unknown_name Undefined variable, function, type, field, variant or effect; an unknown capability kind is capability_kind, an unknown effect is name and effect
E7003 source.missing_move Named linear value consumed without move
E7004 source.not_exhaustive match misses an outcome, variant or default
E7005 source.type_mismatch Expression has the wrong type in a source position
E7006 source.invalid_construct Construct not allowed here; stable reason below
E7007 source.ambiguous Source meaning cannot be determined
E7900 source.internal_compiler_error The frontend produced invalid AIR for this construct: a compiler bug, not a program error; fields air_code, air_message

T0xxx — Runtime traps

Reported in trap records (spec 01 §6), not by the verifier.

Code Kind Meaning
T0001 trap.explicit trap instruction executed
T0002 trap.assert Assertion failed
T0003 trap.overflow Checked arithmetic result not representable
T0004 trap.division_by_zero Division or remainder by zero
T0005 trap.shift_out_of_range Shift amount negative or not less than bit width
T0006 trap.cast_out_of_range Checked cast value not representable in target type
T0007 trap.call_depth Call depth limit (1 024 frames) exceeded
T0008 trap.out_of_bounds Runtime bounds check failed
T0009 trap.unsafe_precondition Unsafe precondition violated (detected)
T0010 trap.foreign_iref An iref was used to access a graph it does not belong to

Source repair candidate kinds

These stable kinds use spec 10 §3. hint MUST equal the registered text. Alternatives, when present, MUST use the unit below; hints alone are not replacements. Advice is selected at the rejecting rule, never by parsing diagnostic prose. Existing illustrative/non-source kinds are outside this registry.

Kind Code Hint Alternatives unit
boolean_negation E7001 Aji boolean negation is not; integer complement is not boolean negation. none
annotate_var_type E7001 Write an explicit type: var name: T = expression;. let may infer its type. none
slice_mut_type E7001 Write slice_mut<T> for a mutable slice type. complete type
slice_ref_type E7001 Write slice<T> for a shared slice type. complete type
explicit_range_end E7001 Write both slice bounds: receiver[start..end]; choose the upper bound explicitly. none
borrow_argument E7001 Write ref place or mut place for an inline borrow argument. prefix
borrow_binding E7001 Bind a borrow with ref name = place; or mut name = place;, rather than a let/var initializer. none
zero_storage E7001 zero is only a whole var initializer: var name: T = zero;; T must be zeroable. none
numeric_cast_modes E7005 Choose as! for a checked conversion (T0006 on overflow) or as% for a wrapping conversion. operator

Closed applicability:

  • boolean_negation: lone ! rejected at primary-expression start. Excludes !=, as! and ! rejected after an expression (such as panic!()). It does not assert that the operand is boolean.
  • annotate_var_type: = found where a var declaration requires its type colon. No advice for let, a missing name or other found tokens; no initializer type is guessed.
  • Slice type kinds: a bare mut/ref parsed in type position immediately followed by slice. Attach at that slice token, retaining the caller's expected token. Emit one complete-type alternative only if the following slice<...> fragment parses as a single-argument slice type. Keep its token spellings (including nested types), remove comments/whitespace and separate adjacent word/number tokens by one space; replace the outer spelling by slice_mut/slice respectively. An incomplete/malformed fragment has hint only. Speculative parsing MUST NOT mutate the original tokens, including >>.
  • explicit_range_end: ] immediately after .. in index syntax. No advice for an omitted start, inclusive ..=, missing for-loop bound or another malformed expression. No receiver or .len alternative is guessed.
  • Borrow kinds: & rejected as the first token of a call argument, excluding enum variant payloads (borrow_argument) or let/typed-var initializer (borrow_binding). Other expression contexts, including the second & in a && b, have no borrow advice. For an argument whose following token is an ordinary identifier, emit ["ref"]; for &mut followed by an ordinary identifier, emit ["mut"]. Other operands have hint only, including &&x. These prefixes do not imply that the referent/mode verifies; binding advice has no prefix alternative.
  • zero_storage: keyword zero rejected at primary-expression start. Accepted typed-var zero initialization has no advice.
  • numeric_cast_modes: integer as rejected by the lossless-widening rule, with unchanged from/to. Alternatives MUST be ["as!", "as%"]. Non-integer casts and other E7005 rules have no such candidate.

E7006 reasons

These stable categories are part of the diagnostic API (spec 15 §10), not new rejection rules. One reason is selected at the rejection site; messages remain optional explanation.

Reason Meaning
move_copy Explicit move of a plain Copy value; excludes borrows, void and never.
move_borrow Explicit move of a borrow/view.
invalid_move Move operand is void or never, rather than a materializable value.
loop_control_outside_loop break or continue without an enclosing loop.
zero_not_zeroable zero initialization of a type without a zero value.
value_block_statement A bare block statement would implicitly discard a non-void value.
unreachable Statement or expression after unconditional divergence.
missing_return A value-returning function can fall through without a value.
invalid_borrow A borrow requires an explicit binding, mode, named parent or argument form.
invalid_borrow_return A borrow return violates source origin, binding, return or worker restrictions.
duplicate_declaration Duplicate type, function, field, variant or parameter declaration.
invalid_declaration An otherwise disallowed declaration shape, such as an empty enum.
invalid_binding Invalid binding shape, rebinding or implicit borrow binding.
invalid_assignment Assignment requires a mutable variable or a permitted stored element/field.
invalid_place Expression is not an addressable place or uses an invalid unchecked projection.
invalid_match Invalid, duplicate or misplaced pattern, outcome or select arm.
invalid_unpack Invalid complete unpack or multi-result binding form.
invalid_expression Value expression uses an unavailable form, such as scalar dereference of a slice.
invalid_operation Invalid intrinsic/call, fallibility handler, multi-result handler or ordering spelling.
invalid_literal Invalid literal shape, duplicate/missing initializer field or borrowed element.
invalid_generic Invalid generic parameter, constraint, argument, entry point or application.
invalid_static_function Static callable contract, parameter use or specialization is disallowed.
implementation_limit A specified frontend/module/type/specialization size or depth limit is exceeded.
invalid_module_mapping Invalid reserved, duplicate or excessive package module mapping.
duplicate_import The same module is imported twice.
import_cycle Cyclic module import.
module_header_mismatch Mapped module header differs from its explicit provider name.
trusted_unavailable A source program/template declares an unavailable trusted boundary.