Troubleshooting
No Implicit Type Coercion
rill never converts between types automatically. Operations that silently coerce in other languages produce errors in rill.
String + Number
"count: " + 5
# Error: Arithmetic requires number, got stringFix: Use string interpolation or explicit conversion.
"count: {5}"
# Result: "count: 5"5 -> string
# Result: "5"Number from String
"42" -> $ + 1
# Error: Arithmetic requires number, got stringFix: Convert with -> number.
"42" -> number -> ($ + 1)
# Result: 43Non-numeric strings throw on conversion:
"abc" -> number
# Error: Cannot convert "abc" to numberNo Truthiness
rill requires actual bool values for conditions. Empty strings, zero, and empty lists are not “falsy.”
Condition Expects Boolean
"hello" ? "yes" ! "no"
# Error: Conditional requires boolean, got stringFix: Produce a boolean explicitly.
"hello" -> .empty -> (!$) ? "yes" ! "no"
# Result: "yes"0 -> ($ == 0) ? "zero" ! "nonzero"
# Result: "zero"Negation Requires Boolean
!"hello"
# Error: Negation requires boolean, got stringFix: Negate a boolean expression.
"hello" -> .empty -> !$
# Result: trueType-Locked Variables
Variables lock to the type of their first assignment. Reassigning a different type fails.
"hello" => $x
"world" => $x # OK: string to string42 => $x
# Error: cannot assign number to string variable $xFix: Use a new variable or convert the value.
"hello" => $x
42 -> string => $x # OK: still a stringCollections lock element types too
A collection locks to its element or field types, not only its kind.
list[1] => $x
list["a"] => $x
# Error: RILL-R001Fix: Annotate the first capture with the wider type.
list[1] => $x:list(union(number, string))
list["a"] => $x
# Result: list["a"]A dict lock is exact, so an extra key halts too. A tuple lock is positional, so a longer tuple halts. A function locks to its full signature, so a function with different parameters halts.
dict[a: 1] => $x
dict[a: 1, b: 2] => $x
# Error: RILL-R001tuple[1] => $x
tuple[1, 2] => $x
# Error: RILL-R001fn(n: number) { $n } => $f
fn(s: string) { $s } => $f
# Error: RILL-R001Fix: Annotate the first capture with the wider type, or use a second name.
Missing Dict Keys
Accessing a key that does not exist throws an error. rill has no undefined or null.
[name: "alice"] => $person
$person.age
# Error: Dict has no field 'age'Fix: Use ?? for a default value, or .?key to check existence.
[name: "alice"] => $person
$person.age ?? 0
# Result: 0[name: "alice"] => $person
$person.?age ? "has age" ! "no age"
# Result: "no age"Dict Assertion Halts on Extra Fields
A :dict(...) assertion names every key the dict may hold. A dict with an extra key halts #TYPE_MISMATCH.
dict[a: 1, b: 2] -> :dict(a: number)
# Error: #TYPE_MISMATCHFix: Convert with -> dict(...) to drop the extra key, or name the key in the type.
dict[a: 1, b: 2] -> dict(a: number)
# Result: dict[a: 1]See Extra and Missing Dict Fields for the full table.
List Index Out of Bounds
["a", "b"] => $list
$list[5]
# Error: RILL-R009Fix: Supply a default with ?? on the index, or check the length first. .at(5) without ?? halts the same way.
["a", "b"] => $letters
$letters[5] ?? "default"
# Result: "default"["a", "b"] => $letters
$letters -> .len -> .gt(5) ? $letters[5] ! "default"
# Result: "default"Pipe Value ($) Outside Pipe
$ refers to the current pipe value. Using it outside a pipe context produces an error.
Fix: Capture with => when you need the value later.
"hello" => $greeting -> .upper
$greeting
# Result: "hello"Empty Collection Operations
Methods like .head and .tail error on empty collections.
[] -> .head
# Error: Cannot get head of empty listFix: Check .empty first.
[] => $list
$list -> .empty ? "nothing" ! ($list -> .head)
# Result: "nothing"Spread Type Mismatch
List spread requires a list or tuple operand. Dict spread requires a dict operand.
"hello" => $str
[...$str]
# Error: RILL-R002Fix: Ensure the spread operand matches the container type.
"hello" -> .split("") => $chars
[...$chars]
# Result: list["h", "e", "l", "l", "o"]Function Parameter Count
Calling a function with wrong argument count produces an error.
fn(a, b) { $a + $b } => $add
$add(1)
# Error: Expected 2 arguments, got 1Fix: Pass the correct number of arguments, or use default parameters.
fn(a, b = 0) { $a + $b } => $add
$add(1)
# Result: 1A Block Argument Halts With an Arity Error
seq, fan, filter, and sort call their function with the element only. A block argument takes the parameters its body reads, so the body must read $ and must not read $@.
list[1, 2] -> seq({ 5 })
# Error: RILL-R045list[1, 2] -> seq({ $@ })
# Error: RILL-R044{ 5 } reads nothing, so it takes no parameter and the element is an excess argument (RILL-R045). { $@ } reads the accumulator, so it requires a second parameter that seq never supplies (RILL-R044).
Fix: Read $, or declare the parameters with fn.
list[1, 2] -> seq({ $ * 5 })
# Result: list[5, 10]fold and acc call their function with two arguments. A function with fewer than two parameters halts RILL-R045, and a third required parameter halts RILL-R044. See Collections for the arity rules.
A Collection Entry Holds a Block That a Read Does Not Select
A block written as a dict value or list element is held, not run. Selecting the entry with $c.name, $c[key], or a dispatch pipe runs it, with $ bound to the enclosing $ for access and to the selector for dispatch. Iteration, .values, spread, equality, and interpolation select nothing, so they halt with #TYPE_MISMATCH.
dict[n: 2, double: { $.n * 2 }] => $d
$d -> $d.double
# Result: 4dict[a: { 1 }] => $d
$d -> .values -> seq({ $ })
# Error: TYPE_MISMATCHFix: Select the entry by name, or write the entry as fn { ... } when you need a function value. See Functions and Code Blocks for held blocks and function values.
Reserved Dict Keys
keys, values, and entries are reserved method names on dicts. Using them as keys produces errors.
[keys: "test"]
# Error: Reserved key 'keys'Fix: Choose a different key name.
[key_list: "test"] => $d
$d.key_list
# Result: "test"Debugging Tips
Use log for Pipeline Inspection
log prints its input and passes the value through unchanged, so it works inline.
"hello" -> log -> .upper -> log -> .len
# Logs: "hello"
# Logs: "HELLO"
# Result: 5Use json to Inspect Structure
[name: "alice", scores: [90, 85, 92]] -> json -> log
# Logs: {"name":"alice","scores":[90,85,92]}Use ^type to Check Types
[1, 2, 3] => $val
$val.^type.name -> log
# Logs: "list"
$val.^type.signature -> log
# Logs: "list(number)"Use Type Assertions to Validate
Insert :type assertions at pipe boundaries to catch unexpected types early.
[1, 2, 3] -> :list(number) -> fan({ $ * 2 })
# Result: list[2, 4, 6]Stream Pitfalls
Re-Iterating a Consumed Stream
A stream can be iterated only once. Passing it to a second collection operator halts execution.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s -> seq({ $ })
$s -> fan({ $ })
# Error: RILL-R002: Stream already consumed; cannot re-iterateFix: Consume the stream once and store results in a variable if you need the data again.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s -> fold("", { $@ ++ $ }) => $full_text
$full_text -> log
$full_text -> .len -> logyield Outside a Stream Function
yield is a keyword scoped to stream function bodies. Using it outside that context is a parse error.
"hello" -> yield
# Error: RILL-P: yield is not valid outside a stream function bodyyield is also invalid inside a stored function defined within a stream body.
fn():stream(number):number {
fn { $ -> yield } => $fn
$fn(1)
}
# Error: yield is not valid in stored functionFix: Use yield only as a terminator in a pipe chain inside the stream function body directly.
fn():stream(string):number {
"first" -> yield
"second" -> yield
return 2
} => $producerCalling $s() Before Consuming the Stream
Calling $s() on a stream that has not been fully iterated triggers internal consumption. All chunks are consumed before the resolution value is returned. This prevents separate chunk processing afterward.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s() # forces internal consumption of all chunks
$s -> seq({ $ -> log })
# Error: RILL-R002: Stream already consumed; cannot re-iterateFix: Iterate chunks first, then call $s() for the resolution value.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s -> seq({ $ -> log })
$s() # safe: stream is closed, resolution is cachedStale Step Access with .next()
Manual stream iteration with .next() creates new step objects. Holding a reference to an old step and calling .next() on it halts execution.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s.next() => $step1
$step1.next() => $step2
$step1.next()
# Error: RILL-R002: Stale step; this step is no longer currentFix: Always reassign the step variable when advancing. Use seq for automatic iteration instead.
use<ext:app> => $app
$app.llm_stream("hello") => $s
$s -> seq({ $ -> log })$s() remains valid on stale steps. Only .next() fails when called on a non-current step.
My Script Halted at an Access
An access on an invalid value halts execution. Common causes: a host function returned an error, a type assertion failed, or a field did not exist.
Symptom: Script stops mid-execution with no apparent syntax error.
Fix: Wrap the risky access in guard to catch the halt and inspect the result.
"hello" => $val
guard { $val.upper } => $out
$out.! ? "halted: {$out.!message}" ! $out
# Result: "HELLO"To find which operation halted, read .!trace:
use<ext:app> => $app
guard { $app.fetch("https://api.example.com") } => $result
$result.!trace -> seq({ log("{$.kind} at {$.site}") })Access halts are catchable. Halts from non-catchable sources (for example error "..." and assert) propagate through guard.
Why Is My Comment a Parse Error?
A # followed by a letter or _ starts an atom, not a comment. A comment needs a space after #. Both examples below halt with RILL-P024.
# Error: atom followed by trailing tokens
list[1, 2] -> .len #count# Error: atom followed by trailing tokens
#TODO fix this laterCause: #count and #TODO lex as atoms, and the tokens after them are not valid syntax.
Fix: Put a space after #, and leave two spaces before an inline comment:
list[1, 2] -> .len # count
# Result: 2A lone #todo on its own line runs silently as a discarded atom statement. The checker warns with ATOM_DISCARDED.
Why Does Comparing .!code to #MY_CODE Halt?
Atoms compare by name, and names are case-sensitive. #MY_CODE is a valid atom, but no halt carries a code outside the core error set, so a comparison against it halts instead of returning false.
guard { 1 / 0 } => $r
# Error: #TYPE_MISMATCH
($r.!code == #MY_CODE)Cause: #MY_CODE is not in the core error set, which .!code treats as closed. The comparison halts #TYPE_MISMATCH, so a misspelled or invented code cannot silently take the wrong branch. Inside on:, the same name is a parse error:
# Error: RILL-P004 '#MY_CODE' is not a core error code
guard(on: #MY_CODE) { $app.fetch($url) }Fix: Compare against a name from the core error set. Hosts report domain detail in the sidecar raw field, so read it with .!field, for example $result.!reason.
Use .! to test validity without comparing atoms:
"hello" => $val
guard { $val.upper } => $result
$result.! ? "invalid" ! "valid"
# Result: "valid"Common core error codes: #TIMEOUT, #AUTH, #FORBIDDEN, #RATE_LIMIT, #QUOTA_EXCEEDED, #UNAVAILABLE, #NOT_FOUND, #CONFLICT, #INVALID_INPUT, #PROTOCOL, #DISPOSED, #TYPE_MISMATCH, #R001, #R999, and the #RILL_R### family. See Built-in Atoms and the Core Error Set for the full list. #ok is a runtime sentinel, not an error code. $r.!code == #ok tests for a valid value, though .! is shorter.
To convert an atom to its string name:
#TIMEOUT -> string
# Result: "TIMEOUT"Guard Did Not Catch My Error
guard catches catchable halts only. Halts from non-catchable sources (for example error "..." and assert) are not caught.
# Non-catchable halt — propagates through guard
guard { error "fatal" }
# Error: non-catchable halt from 'error' propagatesCause 1: The halt originated from error "..." or assert. These are intentional escalations, not recoverable failures.
Cause 2: A filtered guard(on: #CODE) or guard(on: list[#CODE, ...]) did not match the actual error code. Non-matching codes propagate.
use<ext:app> => $app
guard(on: #TIMEOUT) {
$app.fetch("https://api.example.com")
# If this returns #AUTH, the halt propagates — not caught
}Fix for cause 1: Remove guard — the script must stop. If the error is expected, do not use error "..." to produce it. Use ctx.invalidate from the host instead.
Fix for cause 2: Widen the filter or remove it to catch all catchable codes.
"hello" => $val
guard { $val.upper } => $out
$out.!
# Result: falseThe filter is optional. Without it, guard catches every catchable halt. A written guard(on: list[]) is a parse error, and a computed empty list halts #INVALID_INPUT; neither is a catch-all. Options in angle brackets, such as guard<on: #AUTH>, are a parse error (RILL-P025); write guard(on: #AUTH).
Why Does ns::fn() Fail to Parse?
The namespaced host-call form ns::fn() was removed. A script that uses it halts at parse time with RILL-P012 and the message “Syntax removed”.
math::add(1, 2) # Error: RILL-P012 Syntax removedThe pipe-target form fails the same way:
"hello" -> str::upper # Error: RILL-P012 Syntax removedBind the extension with use<ext:name>, then call its members through the variable:
use<ext:math> => $math
$math.add(1, 2)
# Result: 3Nested namespaces become nested dict members, so io::file::read is $io.file.read after use<ext:io> => $io.
See Also
| Document | Description |
|---|---|
| Error Reference | All error codes with causes and resolutions |
| Error Handling | guard, retry, .!, and status probes |
| Types | Type rules and value semantics |
| Design Principles | Why rill works this way |
| Guide | Beginner-friendly introduction |