BlyxDocumentation
Browse chapters
Documentation / Local toolchain

Debug and recover from errors

Locate a syntax error, diagnose a runtime failure, and guard an operation using short-circuit evaluation.

Identify the failing stage

Check the file path first. A syntax error occurs while reading the program structure. A runtime error occurs while executing a valid expression with particular values. An error from a native build can point to a type mismatch or a missing Rust toolchain.

ObservationLikely causeFirst action
A parser line and columnMissing punctuation or an unfinished expressionInspect that token and the preceding statement.
index … out of boundsThe index fell outside the vectorCheck 0 <= i and i < len(v) before at.
dot requires vectors of equal lengthThe inputs contain different numbers of observationsCompare both lengths.
step limit exceededThe budget ran outTrace the loop condition and its updates.

Reproduce the smallest failure

Save fn main() { println!(1 / 0); } as divide.blyx. A syntax check succeeds because the expression is well formed. Running it reports an integer division error and exits with code 4. Replace the zero with 2 and rerun. Whole-number division now prints 0.

Put a guard before division

The example reads count != 0 && total / count > 3. With a zero count the first comparison is false, so evaluation skips the division. Reversing the operands would evaluate the division before discovering the zero.

Limit a test run

A runaway loop can repeatedly evaluate valid code. Use a small positive budget while investigating it. The released interpreter also enforces a separate call-depth limit. Increasing the budget only helps after you have confirmed that the computation progresses.

blyxc run src/main.blyx --max-steps 10000

Try the program

Output Ready
Expected output
false
true
Open in the full playground →

Practice

Make the second call use a nonzero count whose integer quotient is exactly three.

Hint

Keep total at 12 and choose a count that divides it evenly.

Worked solution

The quotient 12 / 4 is 3. The strict > 3 comparison returns false, and the zero-count case also returns false.

Find

above_limit(12, 2)

Replace with

above_limit(12, 4)

Output after the change

false
false