E0282

A ? or a return directly inside a requires or ensures expression, outside any closure. A contract is a condition that evaluates to a Bool, so there is no function to leave. A closure in a contract may use both for itself. Spans the ? expression or the return statement.

Machine-applicable fix: none.

Example

This program fails with E0282.

fn first(xs: List<Int>) -> Option<Int> {
    xs.get(0)
}

fn run(xs: List<Int>) -> Int
    requires first(xs)? > 0
{
    1
}

Fixed

The same program, fixed.

fn run(xs: List<Int>) -> Int
    requires xs.len() > 0
{
    1
}

Listed in the checker notes. oskac explain E0282 prints this entry offline.

All error codes