bynk.contract.impure_predicate
Error A contract predicate uses an effectful or test-only construct; a contract clause must be pure.
A contract clause is checked on every call in the dev and test build, and by the runner on generated inputs, so its predicate must be a pure Bool over the parameters and result. Effects (Effect.pure, ?) and test-only constructs (expect, val, observations, faults, trace) cannot appear in it. State the claim as a plain comparison, and keep assertions and effects in a case.
Example
fn inc(x: Int) -> Int ensures bigger: expect result > x // ✗ `expect` is a test statement
fn inc(x: Int) -> Int ensures bigger: result > x // ✓ a pure `Bool`In the Book
See also
- Every code in its category, Contracts, on the diagnostic index.
bynk explain bynk.contract.impure_predicateshows the same from the installed toolchain, without a network.