B3026: assignment whose value is never read
Catalog status: active. Default severity: warning. Stable name: ineffective-assignment. Family: Flow and effects.
A warning from flow analysis: on every path after this assignment, the variable is assigned again, or its scope ends, before anything reads it, so the value assigned is lost. Flow analysis follows loops (a value read in the next iteration is read) and exception handlers (a value a handler reads is read).
Example (Vada)
function Pick (A, B : Integer) return Integer is
R : Integer;
begin
R := A; -- B3026: overwritten below before it is read
R := B;
return R;
end Pick;Example (Varc)
fn pick(a, b: Integer) -> Integer {
var r: Integer;
r = a; // B3026: overwritten below before it is read
r = b;
return r;
}
What to do
Remove the assignment, or read the value where it was meant to be read. Initial values given in declarations are not reported.
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.