Issue #1220: task::scope … catch in a fn main() without throws lowers to return Err(error) and fails in rustc

Open 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).

Probe

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.

To build

  1. Lower the failure path of 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.
  2. Add a test in tests/compiler/tests/ with the probe and its .stdout (0), at both user_parallelism settings.

Back to Open Issues