task::scope … catch in a fn main() without throws lowers to return Err(error) and fails in rustcOpen and answer this issue on GitHub.
ready · opened 2026-11-04 · updated 2026-11-04 · 0 comments
Found by the async a3 brief (group runtime, 6331c7ab).
use std::task
fn f() -> i64 throws { throw Error("x") }
fn main() {
let r = task::scope fn(s) { s.spawn fn { f() }; 1 } catch { 0 }
print(r)
}
nikaia check accepts it, because the catch handles the scope’s failure. nikaia run lowers the scope’s error path to return Err(error) inside main, which returns (). rustc then refuses it with “mismatched types”. Adding throws to main hides the problem.
task::scope … catch into the catch arm, not into a return Err of the enclosing function, so it works whether or not the function throws.tests/compiler/tests/ with the probe and its .stdout (0), at both user_parallelism settings.