Error reference
Paste an error code such as E4-006, its name, or a few words of the
message, and find what it means and how to fix it. There are 73 errors a program
can actually raise. How to read a report is explained in the
guide.
Lexical errors 1
E1-003InvalidNumberLiteral
A malformed number literal: a letter touching it, an exponent without digits, or a value too large.
Cause and fix
E1-003 is raised for a number literal that is too large to represent (1e400, or one written with hundreds of digits), and for a number that a letter touches: an exponent without digits (1e), a hexadecimal form (0x10), digit separators (1_000), or a word written against a number (2x).
Syntax errors 5
E2-001UnexpectedToken
The token found cannot appear here. Every syntax problem found while tokenizing or parsing is reported with this code.
Cause and fix
The program is not valid CuffScript. The message says what was expected and the caret shows where the parser gave up. The usual causes are a declaration or an assignment that is not written TYPE NAME = value or NAME = value (the old set, change and to forms get a hint that says what to write), a block with no end, a body that is not indented, a missing do:, a space before a colon, a string with no closing quote and a stray character. Put the first error right and run again: later errors are often caused by the first.
A program that raises it, and what the engine prints
number x
[E2-001] Syntax Error at line 1, column 8
|
1 | number x
| ^ expected the end of the line after the statement (got 'x')
hint: to declare 'x' write `number x = value`E2-007InvalidAssignmentTarget
Something that cannot be assigned to.
E2-008NestingTooDeep
Code nested deeper than the nesting limit, or a single expression longer than the expression limit.
Cause and fix
E2-008 is raised for code nested deeper than the nesting limit, or a single expression longer than the expression limit, and E2-009 for a program or shell entry larger than the source size limit. E3-011 is the same kind of error for a pattern: one that is too large or nested too deeply. The values are in limits.
E2-009SourceTooLarge
A program or shell entry larger than the source size limit.
Cause and fix
E2-008 is raised for code nested deeper than the nesting limit, or a single expression longer than the expression limit, and E2-009 for a program or shell entry larger than the source size limit. E3-011 is the same kind of error for a pattern: one that is too large or nested too deeply. The values are in limits.
E2-010DuplicateDeclaration
A name declared again where the same function or program already declares it.
Cause and fix
A name is declared a second time where the same function, or the top level of the program, already declares it: in the same block, in a block inside it, or as a parameter or a loop variable with the name of a variable declared before. Give the second one another name, or assign to the first (total = 2). Two blocks side by side may declare the same name, and so may two functions. It is also raised for a second function of the same name at the top level of one file: both cannot be meant, so rename one or remove it (a later shell entry may still declare a function again).
A program that raises it, and what the engine prints
number total = 1
number total = 2
[E2-010] Syntax Error at line 2, column 8
|
2 | number total = 2
| ^^^^^ 'total' is already declared here
hint: give it a new value with `total = ...`, or choose another namePattern errors 14
E3-001RegexUnclosedGroup
A ( or named capture that is never closed, or a < that does not begin a <name:...> capture.
Cause and fix
A pattern has a ( that is never closed, or a < that does not start a named capture such as <year:[num]4>. Close the group, or escape the character you meant literally: \( or \<.
A program that raises it, and what the engine prints
print("x" matches p"(a")
[E3-001] Regex Syntax Error at line 1, column 21
|
1 | print("x" matches p"(a")
| ^ in pattern "(a": unclosed '(' — missing ')'E3-002RegexUnclosedBracket
A [ that is never closed.
Cause and fix
A pattern has a [ that is never closed. Close it, or write \[ to match a bracket.
A program that raises it, and what the engine prints
print("x" matches p"[num")
[E3-002] Regex Syntax Error at line 1, column 21
|
1 | print("x" matches p"[num")
| ^ in pattern "[num": unclosed '[' — missing ']'E3-003RegexInvalidColonSpacing
Wrong spacing around the colon of a token such as [one:a|b].
Cause and fix
There is a space between a token's word and its colon. Write [one:a|b], with the colon right after the word.
A program that raises it, and what the engine prints
print("x" matches p"[one :a|b]")
[E3-003] Regex Syntax Error at line 1, column 25
|
1 | print("x" matches p"[one :a|b]")
| ^ in pattern "[one :a|b]": no space is allowed before ':' in '[one:...]'
hint: write [one:...] instead of [one :...]E3-004RegexInvalidQuantifierRange
A repeat range or character range that cannot match anything, such as 5~2 or [z-a], or a repeat count above the repeat limit.
Cause and fix
A repeat range must run from the smaller number to the larger. 5~2 cannot match anything. The same code is raised for a character range written backwards, such as [z-a], and for a repeat count larger than the pattern repeat limit (see limits).
A program that raises it, and what the engine prints
print("x" matches p"[num]5~2")
[E3-004] Regex Syntax Error at line 1, column 26
|
1 | print("x" matches p"[num]5~2")
| ^ in pattern "[num]5~2": quantifier range 5~2 has a start greater than its endE3-005RegexStackedQuantifier
Two quantifiers applied to the same item, such as [num]++.
Cause and fix
A pattern item can have one quantifier. [num]++ has two. Keep one of them.
A program that raises it, and what the engine prints
print("x" matches p"[num]++")
[E3-005] Regex Syntax Error at line 1, column 27
|
1 | print("x" matches p"[num]++")
| ^ in pattern "[num]++": quantifiers cannot be stacked directly on top of each other
hint: combine into a single quantifier, e.g. use '+' or a 'N~M' range, not bothE3-006RegexEmptyToken
An empty token or an empty alternative.
Cause and fix
A token with nothing in it, or an alternative with nothing between its bars. [one:] and [one:a||b] are both errors.
A program that raises it, and what the engine prints
print("x" matches p"[one:]")
[E3-006] Regex Syntax Error at line 1, column 21
|
1 | print("x" matches p"[one:]")
| ^ in pattern "[one:]": '[one:...]' has no alternativesE3-007RegexUnknownToken
A bracket token whose name before the colon is not one. A pattern cannot reach it today: an unknown word in brackets is read as a set of characters.
E3-008RegexInvalidEscape
A backslash that escapes nothing, or something that cannot be escaped.
Cause and fix
A backslash must be followed by one of the characters it can escape: [ ] ( ) { } < > + * ? ~ | . \ : !. Pattern escapes such as \d do not exist; use [num]. A backslash at the very end of a pattern is also this error.
A program that raises it, and what the engine prints
print("x" matches p"\d")
[E3-008] Regex Syntax Error at line 1, column 21
|
1 | print("x" matches p"\d")
| ^ in pattern "\d": '\d' is not a recognized escape sequence
hint: CuffScript patterns only support escaping literal symbols such as \. \+ \( \[ — there is no \d/\w/\s style escapeE3-009RegexDanglingQuantifier
A ~ that is neither part of a repeat range nor escaped, such as a~b.
Cause and fix
A ~ that is not part of a repeat range. To match a tilde, write \~.
A program that raises it, and what the engine prints
print("x" matches p"a~b")
[E3-009] Regex Syntax Error at line 1, column 22
|
1 | print("x" matches p"a~b")
| ^ in pattern "a~b": '~' must be followed by a number (as in '~5') or preceded by one (as in '3~5', '3~')
hint: use \~ to match a literal '~'E3-010RegexUnexpectedCharacter
A character that cannot appear at this point of a pattern.
Cause and fix
A closing ), ] or > with nothing to close. Escape it (\)) to match the character itself.
A program that raises it, and what the engine prints
print("x" matches p"a)")
[E3-010] Regex Syntax Error at line 1, column 22
|
1 | print("x" matches p"a)")
| ^ in pattern "a)": unexpected ')' with no matching openerE3-011RegexPatternTooComplex
A pattern larger than the pattern size limit, or nested deeper than the pattern nesting limit.
Cause and fix
E2-008 is raised for code nested deeper than the nesting limit, or a single expression longer than the expression limit, and E2-009 for a program or shell entry larger than the source size limit. E3-011 is the same kind of error for a pattern: one that is too large or nested too deeply. The values are in limits.
E3-101RegexStepLimitExceeded
Matching used more steps than its budget allows.
Cause and fix
A pattern ran past the budget of matching steps. Patterns that nest a repeat inside a repeat, like ([any]*)*, can take an enormous number of steps on a text that almost matches. Simplify the pattern. This one can be caught with or_else; E3-102 (time) and E3-103 (recursion depth) are the same kind of error and are handled the same way.
A program that raises it, and what the engine prints
str s = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!"
print(s matches p"([any]*)*x")
[E3-101] Regex Runtime Error at line 2, column 9
|
2 | print(s matches p"([any]*)*x")
| ^^^^^^^ pattern matching exceeded the maximum step limit (possible catastrophic backtracking)
hint: simplify the pattern — avoid nested unbounded quantifiers like ([any]+)+E3-102RegexTimeout
Matching ran longer than its time budget allows.
E3-103RegexRecursionLimitExceeded
Matching recursed deeper than its limit.
Runtime errors 40
E4-001UndefinedVariable
A variable that has not been declared, or is not visible here.
Cause and fix
A name that was never declared, was declared later in the program, or lives in another scope. Check the spelling. Inside a function, a variable of the main program is only visible after global name.
A program that raises it, and what the engine prints
print(missing)
[E4-001] Runtime Error at line 1, column 7
|
1 | print(missing)
| ^^^^^^^ undefined variable 'missing'E4-002UndefinedFunction
A function that has not been declared.
Cause and fix
A function that does not exist. Check the spelling, and remember that library functions need their use DLC:... line first; length needs one of the string, list or map libraries.
A program that raises it, and what the engine prints
print(missing_fn(1))
[E4-002] Runtime Error at line 1, column 7
|
1 | print(missing_fn(1))
| ^^^^^^^^^^ undefined function 'missing_fn'
hint: check the spelling, or make sure it's declared before this pointE4-003ConstantReassignment
A constant that is changed after it was created.
Cause and fix
A constant, or a constant list, was changed. Declare the value without constant if it has to change. To change a constant list, copy it first into an ordinary list.
A program that raises it, and what the engine prints
constant number MAX = 1
MAX = 2
[E4-003] Runtime Error at line 2, column 1
|
2 | MAX = 2
| ^^^ cannot change constant 'MAX'E4-004InvalidConstantName
A constant whose name is not all uppercase letters, digits and underscores.
Cause and fix
A constant's name must be all capital letters, digits and underscores, so that a constant stands out from a variable: MAX_USERS.
A program that raises it, and what the engine prints
constant number max = 1
[E4-004] Runtime Error at line 1, column 17
|
1 | constant number max = 1
| ^^^ constant name 'max' must be written in ALL CAPS (uppercase letters, digits, underscores only)
hint: for example: MAXE4-005TypeMismatch
A value of the wrong type for an operation.
Cause and fix
An operation was given the wrong kind of value, such as "a" + 1, a comparison between a number and a string, or a library function given a list where it wants a string. Convert explicitly with to_str or to_number.
A program that raises it, and what the engine prints
print("a" + 1)
[E4-005] Runtime Error at line 1, column 11
|
1 | print("a" + 1)
| ^ cannot add str and number
hint: '+' works on number+number, str+str, or list+listE4-006DivisionByZero
Division or remainder by zero, or zero to a negative power.
Cause and fix
A division or remainder by zero, or zero raised to a negative power. Test the divisor before dividing.
A program that raises it, and what the engine prints
print(1 / 0)
[E4-006] Runtime Error at line 1, column 9
|
1 | print(1 / 0)
| ^ division by zeroE4-007ZeroIndexAccess
Position 0, which does not exist (positions start at 1).
Cause and fix
Positions start at 1. Position 0 does not exist; the first element is 1 and the last is -1.
A program that raises it, and what the engine prints
print("abc"[0])
[E4-007] Runtime Error at line 1, column 13
|
1 | print("abc"[0])
| ^ index 0 does not exist — CuffScript indexing starts at 1
hint: use 1 for the first element, or -1 for the lastE4-008IndexOutOfRange
A position outside a list, string or slice.
Cause and fix
A position past the end of a list or string, or a slice that runs past it. Positions run from 1 to the length, and from -1 (the last) backwards.
A program that raises it, and what the engine prints
print("abc"[5])
[E4-008] Runtime Error at line 1, column 13
|
1 | print("abc"[5])
| ^ index 5 is out of range (length 3)E4-009KeyNotFound
A map key that is not present.
Cause and fix
A map has no such key. Ask map_has_key(m, key) first, or recover with or_else.
A program that raises it, and what the engine prints
map m = {"a": 1}
print(m["b"])
[E4-009] Runtime Error at line 2, column 9
|
2 | print(m["b"])
| ^^^ key "b" does not exist in this mapE4-010ArgumentCountMismatch
A call with the wrong number of arguments.
Cause and fix
A function was called with too many or too few arguments. Compare the call with the function's parameters, or with its entry in the function index.
A program that raises it, and what the engine prints
print(type_of(1, 2))
[E4-010] Runtime Error at line 1, column 7
|
1 | print(type_of(1, 2))
| ^^^^^^^ type_of() expects 1 argument(s), got 2E4-015ElementNotFound
A value to remove that is not in the list.
Cause and fix
remove was given a value that is not in the list. Check with contains first, or remove by position with remove at.
A program that raises it, and what the engine prints
list a = [1]
remove "x" from a
[E4-015] Runtime Error at line 2, column 8
|
2 | remove "x" from a
| ^^^ value not found in list — nothing to removeE4-016UnsupportedOperation
An operation not supported here, such as return value outside a function.
Cause and fix
A return with a value at the top level of a program, outside any function. Put the code in a function, or show the value with print.
A program that raises it, and what the engine prints
return 1
[E4-016] Runtime Error at line 1, column 1
|
1 | return 1
| ^^^^^^ 'return' with a value can only be used inside a function
hint: at the top level, show a value with print(...)E4-017StackOverflow
More calls active at once than the call depth limit allows, or nesting inside the engine deeper than the native stack budget allows.
Cause and fix
Recursion went too deep: more calls were active at once than the call depth limit allows. Make sure the recursion has a base case that is always reached. The same error ends nesting inside the engine that reaches the stack budget, such as a field whose default value makes another object of the same class (see limits).
A program that raises it, and what the engine prints
func f() do:
f()
end
f()
[E4-017] Runtime Error at line 2, column 5
|
2 | f()
| ^ maximum call depth (1000) exceeded while calling 'f' — check for infinite recursion
in f, called from:
line 2 in f: f() (999 times)
line 4: f()E4-018NestedFunctionNotSupported
A function declared inside another function.
Cause and fix
A function was declared inside another function. Declare every function at the top level; functions are visible everywhere.
A program that raises it, and what the engine prints
func outer() do:
func inner() do:
end
end
outer()
[E4-018] Runtime Error at line 2, column 5
|
2 | func inner() do:
| ^^^^ nested function definitions are not supported ('inner' is defined inside another function)
in outer, called from:
line 5: outer()
hint: move 'inner' to the top levelE4-019AwaitOnNonAsync
await applied to a function that is not async, or to a value that is not a task.
Cause and fix
await was applied to a call of a function that is not async, or to a value that is not a Task. Declare the function async func, or drop the await; to wait for a task, await the Task value its call gave.
A program that raises it, and what the engine prints
func f() do:
end
await f()
[E4-019] Runtime Error at line 3, column 1
|
3 | await f()
| ^^^^^ 'await' can only be used with an async function; 'f' is not declared async
hint: declare it with 'async func f(...) do:', or call it without 'await'E4-020DeclarationTypeMismatch
A declared type that does not match the value.
Cause and fix
A value does not have the type the variable, field, loop variable or or_else name was declared with: number n = "x", or n = "x" after number n = 1. Store a value of the declared type, or declare the type the value really has; a variable that holds different types is declared any, and so is one that may hold the empty of a failed find or match, because empty is not a str or a match.
A program that raises it, and what the engine prints
number n = "x"
[E4-020] Runtime Error at line 1, column 8
|
1 | number n = "x"
| ^ cannot assign a str value to number variable 'n'
hint: a variable keeps the type it was declared with (number); use 'any' for a variable that holds different typesE4-021InvalidGlobalDeclaration
global outside a function body.
Cause and fix
global name is only meaningful inside a function, where it makes a global variable visible. At the top level every variable is already in reach.
A program that raises it, and what the engine prints
global x
[E4-021] Runtime Error at line 1, column 1
|
1 | global x
| ^^^^^^ 'global' can only be used inside a function body
hint: at the top level, every variable is already globalE4-022ReturnOutsideFunction
return outside any function.
Cause and fix
A bare return outside any function. (With a value, it is E4-016.)
A program that raises it, and what the engine prints
return
[E4-022] Runtime Error at line 1, column 1
|
1 | return
| ^^^^^^ 'return' cannot be used outside of a functionE4-023StopOutsideLoop
stop or skip outside any loop.
Cause and fix
stop ends the nearest loop and skip goes on with its next pass. Both are errors anywhere else, including inside a function that is called from a loop.
A program that raises it, and what the engine prints
stop
[E4-023] Runtime Error at line 1, column 1
|
1 | stop
| ^^^^ 'stop' cannot be used outside of a loopE4-024FractionalIndex
A position or range bound that is not a whole number.
Cause and fix
A position or a range bound that is not a whole number. Round it first with math_floor or math_round.
A program that raises it, and what the engine prints
print("abc"[1.5])
[E4-024] Runtime Error at line 1, column 13
|
1 | print("abc"[1.5])
| ^^^ str index must be a whole number, got 1.5
hint: round it explicitly first (DLC:math's round/floor/ceil)E4-025InvalidArgumentValue
An argument of the right type but a value the function or operator does not accept.
Cause and fix
The argument has the right type, but a value the function cannot use: text that is not a number, a negative square root, an empty list where the function needs one element, and so on. The message says which. Check the value first, or recover with or_else.
A program that raises it, and what the engine prints
print(to_number("abc"))
[E4-025] Runtime Error at line 1, column 7
|
1 | print(to_number("abc"))
| ^^^^^^^^^ to_number() could not parse "abc" as a numberE4-026SizeLimitExceeded
A string, list, map, class declaration, or number of tasks larger than its limit.
Cause and fix
A string, list, map or class declaration grew past its limit, or too many tasks were started or are waiting at once (see limits).
A program that raises it, and what the engine prints
use DLC:string
print(str_repeat("abcdefgh", 1000000000))
[E4-026] Runtime Error at line 2, column 7
|
2 | print(str_repeat("abcdefgh", 1000000000))
| ^^^^^^^^^^ string exceeds the maximum allowed sizeE4-027PureFunctionGlobalAccess
A pure function that reaches a global variable.
Cause and fix
A pure function used a global variable. A pure function can use only its parameters and its own variables.
A program that raises it, and what the engine prints
number g = 1
pure func f() do:
global g
return g
end
print(f())
[E4-027] Runtime Error at line 3, column 12
|
3 | global g
| ^ cannot access global variable 'g' from inside a pure function
in f, called from:
line 6: print(f())
hint: remove the 'pure' keyword to allow thisE4-028NetworkRequestFailed
A network request that failed, timed out, or targeted a blocked address.
Cause and fix
A network request could not be completed: the address is blocked or uses a scheme the library does not support, the server could not be reached, it took too long, or the answer was too large. The message says which. The example uses a scheme that is not supported, so it fails before any connection is made. The documentation checks run with the network switched off, so they do not run this example.
E4-029PureFunctionImpureCall
A pure function that calls a function that is not pure.
Cause and fix
A pure function called a function of the program that is not pure. Mark the called function pure too, or do not use pure here. Library functions may be called freely.
A program that raises it, and what the engine prints
func helper() do:
end
pure func f() do:
helper()
end
f()
[E4-029] Runtime Error at line 4, column 5
|
4 | helper()
| ^^^^^^ a pure function cannot call non-pure function 'helper'
in f, called from:
line 6: f()
hint: mark 'helper' as pure, or remove 'pure' from the callerE4-030ParameterTypeMismatch
An argument that does not match the parameter's declared type.
Cause and fix
An argument does not match the type declared for the parameter (number a). Convert it before the call, or declare the parameter any.
A program that raises it, and what the engine prints
func f(number a) do:
end
f("x")
[E4-030] Runtime Error at line 3, column 3
|
3 | f("x")
| ^^^ f(): parameter 'a' expects number, got str
hint: declared as 'number a' in the parameter listE4-031UnknownClass
A class name that is not declared, used as a type, in extends, in isa or as a constructor.
Cause and fix
A class name that is not declared: as a type, after extends, after isa, or in a with or a declaration. Check the spelling, and remember that a class belongs at the top level of a file or of a module that was loaded with use.
A program that raises it, and what the engine prints
print(1 isa Ghost)
[E4-031] Runtime Error at line 1, column 13
|
1 | print(1 isa Ghost)
| ^^^^^ unknown class 'Ghost'
hint: declare it with `class Ghost do: ... end` at the top level of a file, and check the spellingE4-032InvalidInheritance
A class that inherits from itself, through its ancestors, from something that is not a class, or from Task.
Cause and fix
A class that extends itself, directly or through its ancestors, extends something that is not a class, or extends the built-in Task.
A program that raises it, and what the engine prints
class A extends A do:
end
[E4-032] Runtime Error at line 1, column 17
|
1 | class A extends A do:
| ^ class 'A' cannot extend itselfE4-033UnknownMember
A field or method that the object's class does not have.
Cause and fix
The class has no such field or method. The report lists the fields the class has; the usual cause is a misspelt name.
A program that raises it, and what the engine prints
class Dog do:
str name = "Rex"
end
Dog d = Dog()
print(d.nmae)
[E4-033] Runtime Error at line 5, column 9
|
5 | print(d.nmae)
| ^^^^ class 'Dog' has no field 'nmae'
hint: fields: nameE4-034PrivateMemberAccess
A private field or method used outside the class that declares it.
Cause and fix
A private field or method was used outside the class that declares it. Child classes are outside too: only the methods of the declaring class can use it.
A program that raises it, and what the engine prints
class Safe do:
private number code = 1234
end
print(Safe().code)
[E4-034] Runtime Error at line 4, column 14
|
4 | print(Safe().code)
| ^^^^ 'code' is a private field of 'Safe'
hint: it can only be used inside the methods of Safe itselfE4-035NotAnObject
A .name access or a with block applied to a value that is not an object.
Cause and fix
A .name was used on a value that is not an object, or with was given one. Only objects have fields and methods.
A program that raises it, and what the engine prints
number n = 5
print(n.size)
[E4-035] Runtime Error at line 2, column 9
|
2 | print(n.size)
| ^^^^ cannot read '.size' of a number value: it is not an object
hint: only objects made from a class have fields and methodsE4-036ClassNotTopLevel
A class declared inside a block or a function; classes belong at the top level of a file.
Cause and fix
A class was declared inside a block or a function. Move it to the top level of the file.
A program that raises it, and what the engine prints
if true do:
class Inner do:
end
end
[E4-036] Runtime Error at line 2, column 5
|
2 | class Inner do:
| ^^^^^ a class can only be declared at the top level of a file
hint: move the class out of the block or function that contains itE4-037DuplicateMember
Two fields or methods of one class with the same name.
Cause and fix
A class declares two members with the same name, or a child declares a field its parent already has, or a method has the name of a field. Rename one of them.
A program that raises it, and what the engine prints
class Box do:
number size = 1
number size = 2
end
[E4-037] Runtime Error at line 3, column 12
|
3 | number size = 2
| ^^^^ 'size' is declared twice in class 'Box'E4-038ClassNameConflict
A class named like a function, another class, or a built-in.
Cause and fix
A class has the name of a function, of another class or of a built-in class (Error, Task). Classes and functions share one namespace.
A program that raises it, and what the engine prints
func Report() do:
print("report")
end
class Report do:
end
[E4-038] Runtime Error at line 4, column 7
|
4 | class Report do:
| ^^^^^^ class 'Report' has the same name as a function
hint: classes and functions share one namespace; rename one of themE4-039InvalidClassName
A class whose name does not start with an uppercase letter.
Cause and fix
A class name must start with a capital letter, so that a class stands out from a variable.
A program that raises it, and what the engine prints
class point do:
end
[E4-039] Runtime Error at line 1, column 7
|
1 | class point do:
| ^^^^^ class name 'point' must start with an uppercase letter
hint: for example: PointE4-040MethodNotCalled
A method used as a value, or a field called as a method.
Cause and fix
A method was used without the parentheses that call it, or a field was called like a method. Write object.method(...) for a method and object.field for a field.
A program that raises it, and what the engine prints
class Dog do:
func bark() do:
print("woof")
end
end
print(Dog().bark)
[E4-040] Runtime Error at line 6, column 13
|
6 | print(Dog().bark)
| ^^^^ 'bark' is a method of 'Dog', not a field
hint: call it with parentheses: bark(...)E4-041PureFunctionFieldWrite
A pure function or method that changes a field.
Cause and fix
A pure function or method changed a field. A pure method may read fields but not write them; remove pure, or return the new value instead.
A program that raises it, and what the engine prints
class Counter do:
number n = 0
pure func bump() do:
self.n = self.n + 1
end
end
Counter().bump()
[E4-041] Runtime Error at line 5, column 9
|
5 | self.n = self.n + 1
| ^^^^ a pure function cannot change a field
in Counter.bump, called from:
line 8: Counter().bump()
hint: remove the 'pure' keyword to allow thisE4-042HostFunctionFailed
A function that the host program added reported a failure.
Cause and fix
A function that the host program added with Engine::addFunction reported a failure (Args::fail, or a C++ exception it let out). The message is the host's own, after the function's name. A program can catch it with or_else; what the failure means is in the host's documentation. See embedding.
E4-043TaskDeadlock
A task waits for something that can no longer happen: every task is waiting.
Cause and fix
The program waits for something that can never happen: every task is waiting, and none waits for time to pass or for the network, so none can go on. Two tasks that await each other do this, and so does a task that awaits itself.
A program that raises it, and what the engine prints
list tasks = []
async func wait_for(number which) do:
global tasks
return await tasks[which]
end
add wait_for(2) to tasks
add wait_for(1) to tasks
print(await tasks[1])
[E4-043] Runtime Error at line 8, column 7
|
8 | print(await tasks[1])
| ^^^^^ this waits for something that cannot happen: every task is waiting
hint: a task that waits for another, which waits for it in turn, never finishesE4-044HardwareUnsupported
A part of the device that this device does not have, or that the host did not give (DLC:hardware).
Cause and fix
A DLC:hardware function for a part that this device does not have, or that the host did not give the program: hardware is off unless the host gives it (cuffc --hardware, or Engine::Options::hardware). The message says which function, and the host's reason when it gave one (hw_battery(): this computer has no battery). Ask hw_supports first, or catch it with or_else.
A program that raises it, and what the engine prints
use DLC:hardware
hw_led(0, true)
[E4-044] Runtime Error at line 2, column 1
|
2 | hw_led(0, true)
| ^^^^^^ hw_led() is not supported on this device
hint: ask hw_supports("led") first, or catch the error with or_elseModule errors 7
E5-001ModuleNotFound
A module file that does not exist or cannot be read.
Cause and fix
No such module file. use nothing from ./lib loads ./lib/nothing.cuff, resolved against the folder of the script; check the folder and the file name.
A program that raises it, and what the engine prints
use nothing from ./lib
[E5-001] Module Error at line 1, column 1
|
1 | use nothing from ./lib
| ^^^ could not find module file './lib/nothing.cuff' for 'use nothing from ./lib'
hint: paths are resolved relative to the running script's directoryE5-002ModuleParseFailed
A module file that does not parse.
Cause and fix
A module file was found but does not parse. The report shows the use line and then the module's own error, with its file and line.
A program that raises it, and what the engine prints
use DLC:filesystem
file_write("broken.cuff", "number z = 1 +\n")
use broken from .
[E5-002] Module Error at line 3, column 1
|
3 | use broken from .
| ^^^ failed to parse module './broken.cuff': unexpected end of line in expression
in './broken.cuff' [E2-001] at line 1, column 15:
|
1 | number z = 1 +
| ^ unexpected end of line in expressionE5-004UnknownDLC
A library name that does not exist.
Cause and fix
There is no library by that name. The message lists the libraries that exist.
A program that raises it, and what the engine prints
use DLC:nothing
[E5-004] Module Error at line 1, column 5
|
1 | use DLC:nothing
| ^^^ unknown DLC library 'DLC:nothing'
hint: available libraries: DLC:math, DLC:string, DLC:time, DLC:datetime, DLC:random, DLC:list, DLC:map, DLC:convert, DLC:json, DLC:network, DLC:filesystem, DLC:csv, DLC:hash, DLC:path, DLC:hardwareE5-005DLCFeatureUnavailable
A call into a library that was switched off for this run (--no-network, --no-filesystem).
Cause and fix
E5-005 is raised by a call into DLC:network or DLC:filesystem when the host switched the library off (--no-network, --no-filesystem). The use line itself succeeds.
E5-006ModuleAccessDenied
A module path that is absolute, or resolves outside the allowed directory.
Cause and fix
A module path that is absolute, or that leaves the allowed folder. See the sandbox.
A program that raises it, and what the engine prints
use x from /etc
[E5-006] Module Error at line 1, column 1
|
1 | use x from /etc
| ^^^ absolute module paths are not allowed ('use x from /etc')
hint: use a path relative to the running script, e.g. ./libE5-007ModuleLimitExceeded
Modules imported too deeply, or a module file larger than the source size limit.
Cause and fix
E5-007 is raised when modules load other modules too deeply, or when a module file is larger than the source size limit.
E5-008FilesystemAccessDenied
A file path that resolves outside the allowed directory.
Cause and fix
A file path given to a DLC:filesystem function leaves the allowed folder or is absolute. Use a relative path below the script's folder.
A program that raises it, and what the engine prints
use DLC:filesystem
print(file_read("../x"))
[E5-008] Module Error at line 2, column 7
|
2 | print(file_read("../x"))
| ^^^^^^^^^ DLC:filesystem's file_read("../x") reaches outside the sandboxed root
hint: use a path relative to, and inside, the script's directory (or the host's configured rootDir)Resource limit errors 3
E6-001ExecutionStepLimit
The run exceeded --max-steps.
Cause and fix
E6-001 and E6-002 are raised when a run reaches --max-steps or --timeout; E6-003 when the host runs out of memory. They end the program and cannot be caught: the budget is the host's decision, not the program's.
E6-002ExecutionTimeout
The run exceeded --timeout.
Cause and fix
E6-001 and E6-002 are raised when a run reaches --max-steps or --timeout; E6-003 when the host runs out of memory. They end the program and cannot be caught: the budget is the host's decision, not the program's.
E6-003OutOfMemory
The host ran out of memory.
Cause and fix
E6-001 and E6-002 are raised when a run reaches --max-steps or --timeout; E6-003 when the host runs out of memory. They end the program and cannot be caught: the budget is the host's decision, not the program's.
Program errors 2
E7-001ProgramError
An error raised by the program itself with fail.
Cause and fix
The program raised an error with fail, and nothing caught it. The message is the program's own. An error object of a class that extends Error shows the class name before the message. Catch it with or_else, or make sure the condition that leads to fail cannot happen.
A program that raises it, and what the engine prints
func withdraw(number balance, number amount) do:
if amount > balance do:
fail "not enough money"
end
return balance - amount
end
print(withdraw(10, 50))
[E7-001] Program Error at line 3, column 9
|
3 | fail "not enough money"
| ^^^^ not enough money
in withdraw, called from:
line 7: print(withdraw(10, 50))E7-002AssertionFailed
An assert whose condition was false.
Cause and fix
An assert found its condition false. The message is the one the program gave assert, or "assertion failed" when it gave none. It is an ordinary error: or_else catches it.
A program that raises it, and what the engine prints
func average(list xs) do:
assert(length(xs) > 0, "average() of no numbers")
number sum = 0
loop each number x in xs do:
sum = sum + x
end
return sum / length(xs)
end
print(average([]))
[E7-002] Program Error at line 2, column 5
|
2 | assert(length(xs) > 0, "average() of no numbers")
| ^^^^^^ average() of no numbers
in average, called from:
line 9: print(average([]))Internal errors 1
E9-001InternalError
A bug in the engine: please report it.
Cause and fix
E9-001 is a bug in the engine. If you meet it, please report it with the smallest program that shows it.
Codes the engine never raises (15)
These numbers are reserved. Most syntax problems, for example, are reported as E2-001, whose message says what is wrong.
E1-001UnexpectedCharacter
A character that cannot begin any token.
E1-002UnterminatedString
A string literal that is never closed.
E1-004InconsistentIndentation
Indentation that does not line up with the enclosing block.
E1-005ColonSpaceBeforeNotAllowed
A space before the colon that opens a block.
E1-006UnterminatedComment
A block comment that is never closed.
E2-002ExpectedToken
A specific token was required.
E2-003MalformedFunctionDecl
A malformed function declaration.
E2-004MalformedControlFlow
A malformed if or loop.
E2-005MalformedImport
A malformed use statement.
E2-006UnbalancedBlock
A block opened without a matching end.
E4-011NotCallable
Calling something that is not a function.
E4-012InvalidOperand
An operand an operator cannot work with.
E4-013LocalVariableOutOfScope
A local variable used outside the function that declared it.
E4-014InvalidCollectionOperation
An operation a list or map does not support.
E5-003CircularImport
Modules that import each other in a cycle.
No error matches. Try the code alone (E4-006),
or fewer words from the message.