Skip to content
ZOLO / TE800 Effects · error

function performs an effect but does not declare `with`

A function performs an effect (`!io`, `!net`, `!fs`, ...) it did not declare in its signature.

Why this fires

A perform was reached without the effect being covered — either by the enclosing function's with clause, or by an enclosing handle block. Most of the time this per-site check is superseded by TE809's summary form (one message per boundary function, at its signature), but TE800 still fires directly in two cases where there's no single enclosing "boundary fn" to summarize against:

Top-level code — a perform outside any function has no signature to attach a with clause to:

effect Fs { fn read(p: str) -> str }

let _ = perform Fs::read("x")
//      ^^^^^^^^^^^^^^^^^^^^^ error[TE800]: function '<top-level>' performs 'Fs::read'
//                             but does not declare 'with Fs'

Inside spawn { ... } — a spawned block does not inherit the enclosing function's with clause, even if the function declares it:

effect Fs { fn read(p: str) -> str }

fn run() with Fs {
    spawn {
        let _ = perform Fs::read("x")
        //      ^^^^^^^^^^^^^^^^^^^^^ error[TE800]: function 'run' performs 'Fs::read'
        //                             but does not declare 'with Fs'
    }
}

Fix it

1. Handle the effect locally

effect Fs { fn read(p: str) -> str }

let _ = handle perform Fs::read("x") with {
    Fs::read(_) => "data",
}

2. Re-declare the effect inside spawn

A spawned block is its own effect scope — perform the operation through a helper function that has its own with, or wrap it in its own handle:

effect Fs { fn read(p: str) -> str }

fn run() with Fs {
    spawn {
        let _ = handle perform Fs::read("x") with {
            Fs::read(_) => "data",
        }
    }
}

See also

  • TE801 — an unknown effect name in a with clause.
  • TE802 — calling another function that requires an effect you haven't declared.
  • TE809 — the summary form of this same check, for boundary functions (pub fn, impl methods).
  • /docs/algebraic-effects — algebraic effects and handlers.

Global index

Find your way through Zolo

Try an idea

Start here

9 results

9 results

enespt-br