Skip to content

E6xxx: Runtime errors ​

This page is generated by scripts/docs/gen-error-code-docs.py from the define_codes! registry in src/util/diagnostic/codes/ and locales/en.json. Do not edit it by hand. Change the wording in locales/*.json, change the code table in define_codes!, then rerun python scripts/docs/gen-error-code-docs.py.

Errors raised while the program runs, in the VM or in std native functions.

This family holds 7 codes, all registered in the define_codes! registry, with the category Runtime. See the error code index for the complete inventory.

Code Overview ​

CodeNameCategoryspan exemptTemplateEmission sites
E6001Division by zeroRuntimeYesexpression {expr} divides by zero✅ 5 sites
E6003Array index out of boundsRuntimeYesarray index out of bounds: valid range is 0..{max}, found {index}✅ 3 sites
E6004Stack overflowRuntimeYesstack overflow: recursion depth exceeded limit {limit}✅ 3 sites
E6005Assertion failedRuntimeYesassertion failed: {condition}✅ 3 sites
E6006Function not found (runtime)RuntimeYesFunction not found: '{func}'✅ 1 site
E6007Runtime errorRuntimeYesRuntime error: {message}✅ 3 sites
E6008Key not foundRuntimeYeskey not found: {key}✅ 2 sites

Code Details ​

E6001: Division by zero ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::division_by_zero(expr)
  • Template: expression {expr} divides by zero
  • Message: attempted to divide by zero
  • Help: add a check to prevent division by zero
  • Emission sites: src/backends/interpreter/executor/executor.rs:975, src/backends/interpreter/executor/executor.rs:984, src/backends/mod.rs:180 and 5 more sites
  • Source comment name: 除零错误

E6003: Array index out of bounds ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::runtime_index_out_of_bounds(max, index)
  • Template: array index out of bounds: valid range is 0..{max}, found {index}
  • Message: array index out of bounds at runtime
  • Help: ensure the index is within the array bounds
  • Emission sites: src/util/diagnostic/mod.rs:251, src/util/test_markers.rs:251, src/util/test_markers.rs:341
  • Source comment name: 数组索引越界(运行时)

E6004: Stack overflow ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::stack_overflow(limit)
  • Template: stack overflow: recursion depth exceeded limit {limit}
  • Message: recursion depth exceeded stack limit
  • Help: reduce recursion depth or use iteration
  • Emission sites: src/backends/mod.rs:169, src/backends/interpreter/executor/executor.rs:306, src/util/diagnostic/mod.rs:243
  • Source comment name: 栈溢出

E6005: Assertion failed ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::assertion_failed(condition)
  • Template: assertion failed: {condition}
  • Message: assertion failed at runtime
  • Help: fix the assertion condition or provide valid input
  • Emission sites: src/backends/mod.rs:202, src/std/assert.rs:112, src/util/diagnostic/mod.rs:269
  • Source comment name: 断言失败

E6006: Function not found (runtime) ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::runtime_function_not_found(func)
  • Template: Function not found: '{func}'
  • Help: Make sure the function is defined and spelled correctly
  • Emission sites: src/util/diagnostic/mod.rs:228
  • Source comment name: 函数未找到(运行时)

E6007: Runtime error ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::runtime_error(message)
  • Template: Runtime error: {message}
  • Help: See the error message for details
  • Emission sites: src/util/diagnostic/mod.rs:239, src/util/diagnostic/mod.rs:240, src/util/diagnostic/mod.rs:271
  • Source comment name: 运行时错误(通用)

E6008: Key not found ​

  • Category: Runtime
  • span exempt: Yes
  • Constructor: ErrorCodeDefinition::key_not_found(key)
  • Template: key not found: {key}
  • Message: key not found in dictionary at runtime
  • Help: use dict.has to check if the key exists before indexing
  • Emission sites: src/backends/mod.rs:149, src/util/diagnostic/mod.rs:267
  • Source comment name: 键缺失(#299 §4)