Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

The Verified Corpus

Besides the examples on its pages, this guide keeps a corpus of small, standalone Crush programs in examples/verified/, one behaviour per program, each stored next to the exact output it produces. It is the evidence behind the chapters: every claim about the language was first observed by running one of these programs.

Verified against crush-ast dc0d0278 (the commit in the repository’s CRUSH_AST_COMMIT file). 150 programs.

AreaProgramsCovers
basics/13literals (including hex and binary), print vs io.print, semicolons, one-line expressions, comments, return values, scoping, annotations, Nepali keywords
operators/10arithmetic, comparison, and/or/not, short-circuit, string +, |>, overflow, division by zero
strings/8indexing, str.*, conv.chr/ord, escapes, string and array slices (s[a:b], s[::step]), string methods that don’t exist
collections/11arrays, array.pop and a.pop(), maps (insertion order, subscripts, iteration), collections.*, json.*
control-flow/9if, while/break/continue, ranges, match as expression and statement
functions/5definitions, arity checks, no defaults, top-level visibility, the call-depth quota
closures/11lambdas, function values, calling any expression, capture by reference, counters, loop capture, recursion
structs/11literals, sealing, equality, impl, traits, value semantics, C3, bound methods, constructors
match/3struct patterns, and their compile errors
errors/7try/catch/throw, rethrow, catching run-time faults, what catch can’t catch, result.*
modules/21the import forms, -L and CRUSH_PATH, module rules and errors, structs across files, the struct/trait name clash, pub and __, export
capabilities/12refusal before running, --fs and --fs-root, @capabilities, io.read, sys.args, math.random
polyglot/15--polyglot, -> outputs, JavaScript, chaining, use @lang, isolation, errors, bash
concurrency/7spawn/yield/await, async fn, parallel_map and its rules
annotations/3manifest annotations, @wip, @capabilities
ai-native/2the refused semantic_switch, AI expressions not in source
casm/2running assembly text (.cvms) with --cap

The files

For each program NAME:

FileMeaning
NAME.crush / NAME.cvmsthe program; its first comment lines say what it shows
NAME.outits exact standard output
NAME.errpresent when the program must fail: every line of it must appear in the error output
NAME.flagsthe crush-run flags it needs (--polyglot, --fs --fs-root ., …)
NAME.stdinwhat it reads from standard input (otherwise it reads end-of-file)
NAME.needshost programs it needs (python3, node); skipped, not failed, without them
NAME.envenvironment variables for the run, NAME=value per line (CRUSH_PATH=shared)
NAME.files/the other files the program needs, such as the modules it imports; copied next to it for the run, and not programs of their own

Programs whose first line says PITFALL show behaviour that is wrong today and link the crush-ast issue: when the issue is fixed, the program’s expected output changes and the corpus fails, which is the signal to update the guide.

PitfallIssue
polyglot/header-comment-pitfall: // on a block header → Undefined variable#266

Running it

# crush-ast at the pinned commit, with buckets beside it
git clone https://github.com/nixpt/crush-ast && git -C crush-ast checkout "$(cat CRUSH_AST_COMMIT)"
git clone https://github.com/nixpt/buckets
(cd crush-ast && cargo build -p crush-lang-sdk)

scripts/verify-examples --bin-dir crush-ast/target/debug        # the corpus
scripts/check-examples.py --bin-dir crush-ast/target/debug \
    --crush-ast crush-ast                                         # every block on the pages

verify-examples runs each program in a fresh temporary directory with crush-run run <flags> --max-steps 50000000 and a 60-second timeout, and prints a diff for any output that changed. --bless rewrites the .out files from a run; read the new output before committing it. The repository’s CI runs both scripts against the pinned crush-ast commit on every pull request.