-
Notifications
You must be signed in to change notification settings - Fork 0
Errors and Gotchas
Dimitri Mansour edited this page Aug 28, 2026
·
5 revisions
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.
-
0and""are truthy. Usex == 0orlen(s) == 0explicitly. -
Assignment needs a prior
let.x = 1on 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; checklenfirst. -
Lists are shared references, so
push(f(l), x)may mutate the caller's list. Copy withl + []when you need a snapshot. -
storestringifies. Numbers come back as strings; wrap reads innum(). - A reloaded chunk restarts the program from line 1. Persist anything important to disk.
-
peers()includes this pot, so filter yourself out when iterating;broadcastalready skips you. -
Typing
stopwhile a program is running halts it instead of feedingread(). -
sleepcounts game ticks, not seconds — multiply seconds by 20. -
Unloaded pots vanish from the network, and
sendto them returnsfalse. Check the return value if delivery matters.