B2021: an enclave's variable outside an Abstract_State
Catalog status: active. Default severity: error. Stable name: enclave-state. Family: Types and constraints.
A proof enclave's own variables are its state: they are declared in its private part or body and named by an Abstract_State, so that every operation that uses them says so in its Global, and the enclave's state invariant is assumed on entry to those operations and proved on their exit. A variable in the visible part could be changed by any client, between operations, behind the invariant's back.
Example (Vada)
package Lists
with Annotate => (Verada, Enclave)
is
type List is limited private;
Lists_Made : Natural := 0; -- visible to clients
...What to do (Vada)
Name the state on the package and declare the variable in the body, its constituent:
package Lists
with Annotate => (Verada, Enclave), Abstract_State => State
is
...
function Lists_Made return Natural with Global => State;with Refined_State => (State => Made) on the body and Made : Natural := 0; in it.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See types and constraints, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.