DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B2017: a type holding an enclave's pointers is not limited private

Catalog status: active. Default severity: error. Stable name: enclave-type-not-limited. Family: Types and constraints.

A proof enclave (Annotate => (Verada, Enclave)) lets its bodies share cells between pointers, which ownership would forbid, and keeps the sharing behind its spec. A type the spec declares whose full view holds the enclave's pointers must be limited private: a copy of a value would share the original's cells, so two objects would change together. It must not be tagged either: a type derived from it outside the enclave could override its operations, and a dispatching call inside the enclave would run a client's code on an object in the middle of an update.

Example (Vada)

package Lists
  with Annotate => (Verada, Enclave)
is
   type List is private;   --  copies would share cells
   ...
private
   type Node;
   type Node_Ptr is access Node;
   ...
   type List is record
      Head : Node_Ptr;
   end record;
end Lists;

What to do (Vada)

Declare the type limited private (and not tagged). If copies are wanted, give the enclave a Copy operation whose postcondition says the copy has the same model.

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.