DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B2029: a function with side effects called other than as an assignment's or a declaration's value

Catalog status: active. Default severity: error. Stable name: side-effect-call-place. Family: Types and constraints.

A function with Side_Effects may write globals and out or in out parameters, raise exceptions and run for ever, like a procedure. So that its effects happen at a known point and in a known order, it is called only as the whole value of an assignment statement or of an object declaration, never inside another expression, a contract or an assertion.

Example (Vada)

   function Next return Integer with Side_Effects;
   ...
   X := Next + 1;

What to do (Vada)

Call it on its own, then use its value:

   X := Next;
   X := X + 1;

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.