Wado

core:eval

Compile and run a Wado program from a test.

[eval] takes a whole program as one source string, compiles it as a wasi:cli/command, runs it, and returns what it wrote and how it stopped. It is for testing code generators: generate a program, evaluate it, and assert on its output.

Only wado test supports it, and a program for any other world that reaches this module does not compile. The evaluated program can use stdout, stderr, exit, and wasi:random/insecure and insecure-seed. Which other interfaces the host links is not decided yet. An import it does not link stops the program before it runs, as [EvalError::Unavailable]. Its use items may name the standard library (core:* and wasi:*) and the calling package's [dependencies], and nothing else. Every outcome but a compile timeout is cached, keyed by the compiler, the knobs, the budget, the source and the dependency files it read. See WEP 2026-09-26 (Eval).

Synopsis

let out = eval(`use { println, Stdout } from "core:cli";
export fn run() with Stdout { println("hello"); }`).unwrap();
assert out.status matches { Exited(0) };
assert out.stdout == "hello\n";

Globals

pub global DEFAULT_FUEL: u64

The fuel an evaluated program runs on unless the caller names another budget. Running out stops it with [Status::OutOfFuel].

Functions

pub fn eval(source: String, fuel: u64 = DEFAULT_FUEL) -> Result<Output, EvalError> with EvalHost

Compiles source as a wasi:cli/command program and runs it under fuel.

Err means the program never ran. Ok means it ran, however it stopped; Output.status says how. stdout and stderr are decoded as UTF-8, with U+FFFD where the bytes are not.

Effects

pub interface EvalHost

Host interface behind core:eval. It compiles and runs one Wado source and returns the outcome as raw data; core:eval decodes it. Only wado test supplies it. See WEP 2026-09-26 (Eval).

fn run(source: String, fuel: u64) -> Outcome

#[cm("core:eval/eval-host@0.1.0#run")] #[cm_params("source", "fuel")]

Compile source as a single-module wasi:cli/command program and run it under fuel.

Structs

pub struct Output

What a program that ran wrote, and how it stopped. Output written before a trap is kept.

stdout: String

stderr: String

status: Status

pub struct CompileFailure

A source that did not compile.

rendered: String

The report wado compile would print.

codes: List<String>

The Code of each error, in report order.

Variants

pub variant EvalError

Why a program never ran.

CompileFailed(CompileFailure)

CompileTimedOut

The compile ran past the host's time limit.

Unavailable(String)

The program imports an interface the host does not link; the payload names it.

pub variant Status

How a program that ran came to stop.

Exited(i32)

Trapped(TrapKind)

OutOfFuel

OutOfMemory

Enums

pub enum TrapKind

Why a run stopped with a trap.

Unreachable

StackOverflow

MemoryOutOfBounds

TableOutOfBounds

IndirectCallToNull

BadSignature

IntegerOverflow

IntegerDivisionByZero

BadConversionToInteger

NullReference

ArrayOutOfBounds

AllocationTooLarge

CastFailure

Other