← SPL reference

Common errors

Typical failures you will see from the interpreter, and what usually causes them. For structured handling in SPL, see Errors & exceptions.

UndefinedVariableError
Reading an identifier that is not bound in any scope—typo, wrong name, or using a variable that only existed inside a block or loop after that block has ended ( scoping).
DivisionByZeroError
math.div with second argument zero. Catch with error.except(error.DivisionByZeroError).
IndexOutOfRangeError
List, tuple, or string index out of bounds ( list.get, string.getChar, tuple.get, etc.).
FileNotFoundError / IOError
file.readline, file.write, or file.append failed (missing file, permission, or other OS error). Paths must stay under the working directory (no ..).
Wrong type for print.* or return.*
These calls are typed: print.number rejects bools; print.string requires a real string. Fix the expression or convert first.
Error: test.break used outside of a loop
test.break (or test.continue) only works inside test.forLoop or test.while, not inside a bare function body unless that call is nested in a loop.
Error: Undefined Function: name
function.name was called but no functionDefine.name exists in this interpreter run (typo, or define after use without use loading the file first).
function.name expects N args, got M
Argument count does not match the functionDefine parameter list.
Loop exceeded maximum iterations
test.forLoop and test.while cap iterations (100,000). Usually an infinite or overly long loop.
Lexer / parser errors
Unknown characters, missing end;, unclosed block, or malformed use path. The message includes a line number.
error.try without matching except
error.try(): must be followed immediately (next statements) by one or more error.except(...): blocks. Otherwise the standalone error.try block raises at runtime.
function.call first argument must be function.ref(...)
The first argument to function.call must be a value produced by function.ref, not a bare function name.
list.sort failed: ...
Wrong element types for the chosen key (e.g. numeric on non-numeric values), or invalid key string. Keys are alpha, numeric, ascii, utf-8, utf-16, utf-32.
this.field outside of class / outside of constructor
this.name is only valid while an instance method or constructor is running. this.field = expr; is only valid in constructorDefine, not in ordinary methods. See Classes & OOP.
private field … / method.* outside of instance method
Reading a private field from outside the instance, or using method.foo(...) when no constructor or instance method is active (use obj.foo(...) after class.createObj).
Cannot resolve use / ambiguous use
Library file not found, or extensionless import matches more than one file—add an explicit extension or set the host opt-in flag documented for each language.