Saltar al contenido
TE814 · Efectos · error

`handle … with h` exige un handler-valor

`h` debe ser algo cuyo tipo sea `handler<…>`. Si resuelve a otra cosa, no hay conjunto de brazos al que despachar las operaciones realizadas.

Why this fires

handle <expr> with h requires h to be a handler value — something whose type is handler<...>. If h resolves to anything else, there's no arm set to dispatch the performed operations to.

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

fn run() with Fs -> str {
    return perform Fs::read("x")
}

let not_a_handler = 42

fn main() {
    let _ = handle run() with not_a_handler
    //                         ^^^^^^^^^^^^ error[TE814]: `handle expr with h` requires
    //                         `h: handler<...>`, got `int`
}

Fix it

Pass an actual handler value:

let h = handler {
    Fs::read(_p) => "stub",
}

fn main() {
    let _ = handle run() with h   // ok
}

See also

Véase también

Buscar en Zolo

9 resultados

en