OxL Справочник OxL
РусскийEnglish

error contract

error Стандарт: [§6.7]

Некорректный requires, ensures или invariant.

What it means#

Contract clauses are boolean expressions (§6.7, §4.2). requires may use the parameters, ensures may additionally use result and old(e), and invariant ranges over the fields. A clause of a non-boolean type, or one that uses a name that is not available in that position, is rejected.

Example#

oxl✓ проверяется в CI
fn withdraw(n: i32, amt: i32) -> i32 pure
  requires old(n) > 0      // <- contract (`old` is defined for ensures only)
  => n - amt
error
contract

How to fix#

oxl✓ проверяется в CI
fn withdraw(n: i32, amt: i32) -> i32 pure
  requires n > 0
  ensures result == old(n) - amt
  => n - amt

Make the clause a boolean expression over names visible there. Contract checks are on in the dev and test profiles and a violation panics.

See also#

OxL 1.0.0-beta · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства