Skip to content

Errors and Troubleshooting

Errors carry a category and usually a hint. Abort is the default; see failure model.

Categories

Syntax

Missing ;, ), ], }, or malformed function / loop syntax.

Name

Undeclared or out-of-scope name; missing use / use mut; undefined function.

Type

Wrong assign / argument / return type; builtin called on the wrong kind of value.

Execution

Runtime failures that still abort as Echo errors:

  • List index out of range; missing hash key; bad method use; invalid format() placeholder
  • assert / fail abort (E2819 / E2825)
  • expect / expectEq / expectNeq abort outside echo test (E2826 / E2827 / E2828); under echo test they record and continue
  • List map / filter callback errors (E2829E2831)
  • List reduce (E2832E2834); forEach (E2835E2836); flatMap (E2837E2839)
  • List some / every / findIndex (E2840E2841; non-bool result is E2831)
  • chunk() size (E2842); rangeList / rangeListInclusive bounds (E2843)
  • Hash mapValues (E2844E2845); list flatten (E2846); list partition (E2847E2848; non-bool is E2831)
  • const reassignment / mutation (E3201E3204)
  • Destructuring length / shape (E3205E3207); missing hash keys reuse E2711
  • Exact object shape: extra field E3208, missing field E3209
  • Non-exhaustive switch without else (E3210)

Codes worth knowing

fail(message) always aborts (E2825). assert(cond, message) aborts when cond is falsy (E2819). Same diagnostic shape.

expect(cond, message) requires a bool (E2826). expectEq / expectNeq use Echo == (E2827 / E2828).

List HOF callbacks:

FamilyNon-functionArityOther
map / filterE2829unary → E2830non-bool from filterE2831 (also hash filter)
reduceE2832not binary → E2833result type ≠ initE2834
forEachE2835not unary → E2836
flatMapE2837not unary → E2838non-list result → E2839
some / every / findIndexE2840not unary → E2841non-boolE2831
partitionE2847not unary → E2848non-boolE2831
hash mapValuesE2844not unary → E2845

chunk size not an int >= 1E2842. rangeList / rangeListInclusive non-int bounds → E2843. flatten top-level non-list → E2846.

const: reassignment E3201; mutate through the const name E3202; mutate a frozen value via another name / parameter E3203; use mut on const E3204.

Destructuring: length mismatch E3205; list pattern on non-list E3206; hash pattern on non-hash E3207. Missing hash keys → E2711. Exact extras / missing → E3208 / E3209.

for / range by 0E2702 (also non-convertible range bounds).

Lint is not a runtime error

echo lint prints path:line:col: rule: message and exits 1 on findings. Rules: unused-local, unused-function, unused-import, comparison-to-bool, redundant-by-one, empty-block, shadow-builtin, test-naming, self-assign, unreachable-after-fail. Zero-arg fn test* is not unused-function. test-naming flags a top-level fn that looks like a test but is not a zero-arg testXxx unit.

Example

echo
count = 1;

Name error: count was never declared.

Notes

  • Non-plain mode: some errors/warnings use Rich panels.
  • --plain: simple text.
  • Hints are printed for common mistakes.

Common Fixes

  • Declare before assign
  • Add the missing semicolon
  • Add use or use mut inside functions
  • Check list indexes and hash keys
  • Match declared types

See Also

Echo is in active development. The docs reflect the current implementation.