DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
B3011: global might be read before it is assigned
Catalog status: active. Default severity: error. Stable name: uninitialised-global. Family: Flow and effects.
A library-level variable without an initial value is read by the program, directly or by a subprogram it calls, before anything assigns it. Elaboration does not give it a value.
Example (Vada)
Count : Natural; -- no initial value
...
State.Bump; -- Bump reads CountExample (Varc)
pub var count: Natural; // no initial value
...
State.bump(); // bump reads count
What to do
Give the variable an initial value where it is declared, or assign it before the first read.
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.