DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B4108: predicate check might fail

Catalog status: active. Default severity: error. Stable name: predicate-check. Family: Executable checks.

A subtype with a Static_Predicate or Dynamic_Predicate (RM 3.2.4) admits only the values of its base subtype that satisfy the predicate. Each time a value becomes a value of the subtype (an object's initialisation or assignment, a parameter, a function result, a conversion) the predicate is checked. The prover found a value that might not satisfy it.

Inside a subprogram, the prover assumes that its parameters satisfy their subtypes' predicates; callers learn that results and out parameters do.

Example (Vada)

   subtype Even is Integer with Dynamic_Predicate => Even mod 2 = 0;

   function Next (E : Even) return Even is (E + 1);   --  odd

Example (Varc)

    subtype Even = Integer @Dynamic_Predicate(Even %% 2 == 0);

    fn next(e: Even) -> Even = e + 1;   // odd

What to do

Make the value satisfy the predicate (E + 2 here), or let the subprogram's contract exclude the values for which it cannot.

Regression source and further reading

Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.

See executable checks, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.