Pular para o conteúdo
TE814 · Efeitos · error

`handle … with h` exige um handler-valor

`h` precisa ser algo cujo tipo seja `handler<…>`. Se resolver para outra coisa, não há conjunto de braços para despachar as operações 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

Veja também

Buscar no Zolo

9 resultados

en