Ruta graveolens  ·  notes from a language experiment  ·  cultivated since 2025

E0506: Question err type mismatch

CodeCategoryStability
E0506Control flowPermanent

Explanation

The operand and enclosing function both use the trusted standard-library Result, but their error types are different. ? returns the operand's Err(e) payload through the enclosing function's own Result producer, and Rue does not perform error conversion, so the two error types must be identical.

Likely cause

A called operation returns Result(T, E1) while its caller declares Result(U, E2) with a different error type. Make the error types match or explicitly map the error with match before propagating it; ? does not invoke a conversion.

Examples

Propagate a different Result error type

const result = @import("std/result.rue");
fn fallible() -> result.Result(i32, i32) {
    let R = result.Result(i32, i32);
    R.Ok(42)
}
fn run() -> result.Result(i32, bool) {
    let R = result.Result(i32, bool);
    let value = fallible()?;
    R.Ok(value)
}
fn main() -> i32 {
    let R = result.Result(i32, bool);
    match run() { R.Ok(value) => value, R.Err(_) => 0 }
}

Use the same Result error type

const result = @import("std/result.rue");
fn fallible() -> result.Result(i32, i32) {
    let R = result.Result(i32, i32);
    R.Ok(42)
}
fn run() -> result.Result(i32, i32) {
    let R = result.Result(i32, i32);
    let value = fallible()?;
    R.Ok(value)
}
fn main() -> i32 {
    run();
    0
}

References