LYR-SEM0212
a task's handle dropped
An expression statement starts a task with spawn or Thread.spawn and drops the Task it gives; a scope's spawn is left alone, the scope awaits it.
Explanation
A task's handle is the only way to its value and to its error: dropped, nobody awaits the task, and what it throws is lost without a word.
Await the handle, or start the task with spawnDetached, which says that nobody will. let _ = spawn(…) drops it on purpose.
Wrong
import std.task { spawn };
fn main(): void {
spawn(() => 1);
}
Right
import std.task { spawn };
fn main(): void throws Error {
let task = spawn(() => 1);
let _ = try task.await();
}