XO0801: child or group task error does not convert to the enclosing error type
If a task fails with an error that no await consumes, the scope cancels everything else and the error propagates out of the scope as if by ?, so it must convert to the enclosing function’s error type. The same holds for tasks on a task group. When the group or scope handle came from outside the function, a task started on it must not fail unless its handle is bound and awaited. Bind the handle and handle t.await, handle the error inside the task, or declare a compatible error type. See core 7.1.
Example
enum E { Boom }
fn work() -> Int ! E { 1 }
fn f() {
scope s {
s.spawn(fn() { work() })
}
}Fix
enum E { Boom }
fn work() -> Int ! E { 1 }
fn f() -> Int {
scope s {
let t = s.spawn(fn() { work() })
t.await.ok() ?? 0
}
}Run xo explain XO0801 for this text in a terminal, or see
section 10.6 of the specification.