Rellum Rellum

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

Canonical fixes

Before:

parse(s: String) : Int = parse_result(s)?

After:

parse(s: String) : Result[Int, String] = ok(parse_result(s)?)

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)?