Skip to content

Errors and Gotchas

Dimitri edited this page Aug 28, 2026 · 5 revisions

Errors

Two kinds, both printed into the console in red.

Compile errors happen before anything runs and abort the whole run:

[compile error] line 3: expected '{' after if condition

Runtime errors stop the program where it stood:

[error] line 12: index 5 out of range (length 3)

There is no try/catch and no way to trap an error. Defensive code checks first:

if len(parts) > 1 { print(parts[1]) }
let value = load("k")
if value == nil { print("not set") }

Common runtime errors: undefined variable 'x', expected a number, got string, division by zero, index N out of range, <fn> expects N argument(s), got M, nil is not callable, call stack overflow, unknown side 'x', unknown item 'x'.


Gotchas

  • 0 and "" are truthy. Use x == 0 or len(s) == 0 explicitly.
  • Assignment needs a prior let. x = 1 on a fresh name is a runtime error, not an implicit declaration.
  • No closures, no nested functions. Share state through globals.
  • < and friends are numbers only — you cannot sort strings with them.
  • Out-of-range indexing errors rather than returning nil; check len first.
  • Lists are shared references, so push(f(l), x) may mutate the caller's list. Copy with l + [] when you need a snapshot.
  • store stringifies. Numbers come back as strings; wrap reads in num().
  • A reloaded chunk restarts the program from line 1. Persist anything important to disk.
  • peers() includes this pot, so filter yourself out when iterating; broadcast already skips you.
  • Typing stop while a program is running halts it instead of feeding read().
  • sleep counts game ticks, not seconds — multiply seconds by 20.
  • Unloaded pots vanish from the network, and send to them returns false. Check the return value if delivery matters.
  • A bad item name is an error, not a 0. inv_count/inv_find/inv_move throw on anything not in the item registry, so a typo surfaces immediately.
  • inv_move lands in the same slot a hopper would. Which face you move into decides the slot — e.g. a furnace takes fuel from the side and input from above — it isn't free-for-all slot access.

See also: Examples · Wiki Home

Clone this wiki locally