E1845: documentation promises that a result cannot fail

View source

A public verb returns a Result, and its docstring says that it always succeeds (ADR-0041).

A public verb returns a Result, and its docstring says that it always succeeds (ADR-0041). A Result has an Err variant, so the type cannot guarantee that, and the documentation would promise behavior that the verb does not give. The check looks for always succeeds, never fails, cannot fail and no errors. The message is documentation promises behavior that the declared result contract cannot guarantee, naming the declaration, and the error points at the declaration.

Example

actus
"""Return the count in Ok and a typed error in Err; the verb never fails."""
open verb count() -> Result[Int, Int] {
    return Ok(7);
}

verb main() {
}

Fix

Document the Err variants and the conditions that produce them. If the verb cannot fail, return the value itself instead of a Result.

actus
"""Return the count in Ok, or a typed error in Err when the count is unknown."""
open verb count() -> Result[Int, Int] {
    return Ok(7);
}

"""Entry point of the example; it does nothing and returns no value."""
verb main() {
}

Run actus explain E1845 in your terminal to read this entry offline. Browse Strict & toolchain or all error codes.