Open and answer this issue on GitHub.
ready · opened 2026-11-01 · updated 2026-11-01 · 0 comments
Found by the builder for #1120 on 2026-11-01. The defect is also in the binary from before that fix.
A function can have both of these:
throw Negative,fn(i64) -> i64 sync throws that it runs.When it does, the parameter’s call scoped(n)? is lowered into the function’s Thrown<Negative>. That conversion fails: rustc finds no From<Box<dyn Error>>.
It looks like the ADR-351 D4 throw set counts the errors of a code call as known, when they are an open Box<dyn Error>.
struct Negative { why: String }
impl Error for Negative { fn message(ref self) -> String { return self.why.clone() } }
fn checked(n: i64, scoped: fn(i64) -> i64 sync throws) -> i64 sync throws {
if n > 100 {
throw Negative { why: "big" }
}
return scoped(n)
}
fn main() {
let k: fn(i64) -> i64 sync throws = fn(x) {
if x < 0 {
throw Negative { why: "negative" }
}
return x * 2
}
let d = checked(21, fn(n) { return k(n) }) catch {
println(f"refused: {error}")
return
}
println(f"{d}")
}
Expected output: 42. Actual: rustc refuses the program (From<Box<dyn Error>> is not implemented for Thrown<Negative>).
Box<dyn Error>), or widen the Thrown enum by an open arm. Follow ADR-351 D4.tests/compiler/tests/ built from the probe, with its .stdout. Then add the throws case to a_function_type_takes_a_function.nika (#1120 left it out because of this defect).