Why this fires¶
A handle ... with { ... } block has two arms for the same effect operation.
effect Fs { fn read(p: str) -> str }
fn run() with Fs {
let _ = perform Fs::read("x")
}
fn driver() {
handle run() with {
Fs::read(_) => "first",
Fs::read(_) => "second",
// ^^^^ error[TE806]: duplicate handler arm for 'Fs::read'
}
}Fix it¶
Keep exactly one arm per operation:
fn driver() {
handle run() with {
Fs::read(_) => "first", // ok — the only arm for Fs::read
}
}See also¶
TE803— ahandleblock doesn't cover every operation of an effect.TE804— a handler arm names an operation the effect doesn't have.- /docs/algebraic-effects —
handleblocks and handler arms.