E1130: bounded contract is exceeded or cannot be proven

View source

meta bounded(...) states resource limits for a verb, such as max_iterations: 4u32 (ADR-0095).

meta bounded(...) states resource limits for a verb, such as max_iterations: 4u32 (ADR-0095). The compiler computes a worst case for the body. Sequential work adds up, a branch counts as its largest arm, and a loop multiplies its body by its proven count. The error is reported when:

  • the worst case is larger than the limit;
  • a loop has no proven bound, for example a range with a runtime end;
  • the verb calls a verb that has no bounded contract of its own;
  • the verb calls itself, directly or through other verbs.

For an overrun the message names the dimension, the limit and what the body requires. For the other causes it says that the contract cannot be proven and gives the cause in words, such as the body has a recursive call path or callee helper declares no bounded contract. A callee without a contract is reported under max_calls, and a recursive call path under max_call_depth.

Example

actus
meta bounded(max_iterations: 4u32)
verb scan() -> Int {
    for erg index: u32 in 0u32..8u32 {
    }
    return 0;
}

verb main() {
}
actus
meta bounded(max_iterations: 100u32)
verb scan(erg count: u32) -> Int {
    for erg index: u32 in 0u32..count {
    }
    return 0;
}

verb main() {
}
actus
meta bounded(max_call_depth: 8u32)
verb down(erg n: Int) -> Int {
    return down(n: erg n);
}

verb main() {
}

Fix

Raise the limit to the proven worst case, or make the loop count a fixed value.

actus
meta bounded(max_iterations: 8u32)
verb scan() -> Int {
    for erg index: u32 in 0u32..8u32 {
    }
    return 0;
}

verb main() {
}

Run actus explain E1130 in your terminal to read this entry offline. Browse Modules & rules or all error codes.