DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
B3006: function with a side effect
Catalog status: active. Default severity: error. Stable name: function-side-effect. Family: Flow and effects.
Functions in Verada are side-effect free: they may not write globals, directly or through a procedure they call, and may not have out or in out parameters. This keeps expressions, contracts and assertions free of hidden state changes.
Example (Vada)
function Next_Id return Natural is
begin
Calls := Calls + 1; -- a write to package state
return Calls;
end Next_Id;Example (Varc)
pub fn next_id() -> Natural {
calls += 1; // a write to package state
return calls;
}
What to do
Make it a procedure with an out parameter for the result.
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See flow and effects, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.