S0091: ? requires Result-returning function
Generated from rellum-diagnostics/src/db.rs.
Explanation
The ? operator propagates errors by returning early from the enclosing pure function. That enclosing function must return Result[T, E], otherwise there is no Result error channel to receive the propagated err value.
Common causes
- using ? in a function that returns Int, String, Unit, or another non-Result type
- forgetting to annotate a function as returning Result
- using ? in top-level, feedback, or effect contexts
Canonical fixes
- change the enclosing function to return Result
Before:
parse(s: String) : Int = parse_result(s)?
After:
parse(s: String) : Result[Int, String] = ok(parse_result(s)?)
- handle the Result explicitly with match
Before:
value = parse_result(s)?
After:
value = match parse_result(s)
ok(v) => v
err(_) => fallback
Code example
parse(s: String) : Int = parse_result(s)?