E1067: cannot infer which Result is built

View source

Ok(value) and Err(value) build a Result[T, E], but the value alone does not say what T and E are.

Ok(value) and Err(value) build a Result[T, E], but the value alone does not say what T and E are. The compiler takes them from the type that the context expects, such as a declared binding type or the return type of the verb. When there is no such type the constructor cannot be resolved. The message shows the spelling that always works, Result[T, E].Ok(...). The error points at the constructor.

Example

actus
verb main() {
    erg r = Ok(1);
}

Fix

Give the binding its type, or name the full Result type at the constructor.

actus
verb main() {
    erg r: Result[Int, Int] = Ok(1);
    drop(r);
}
actus
verb main() {
    erg r = Result[Int, Int].Ok(1);
    drop(r);
}

Run actus explain E1067 in your terminal to read this entry offline. Browse Ownership & types or all error codes.