DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
B3004: global used with another mode than its contract says
Catalog status: active. Default severity: error. Stable name: global-mode. Family: Flow and effects.
The Global contract gives a variable a mode the body does not respect: an Input that is written, an Output whose value on entry is read or that is not written on every path, or a Proof_In used outside assertions.
Example (Vada)
procedure Record_Total with Global => (Input => Count, Output => Total);
...
if Count > 0 then
Total := Total + Count; -- reads Total, and does not always write it
end if;Example (Varc)
pub fn record_total() @Global(Input => count, Output => total) {
if count > 0 {
total += count; // reads total, and does not always write it
}
What to do
Use the mode the advice gives (often In_Out), or change the body so that it matches the contract.
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.