On this page
B6004: move out of an in parameter
Catalog status: active. Default severity: error. Stable name: move-from-observed. Family: Ownership and finalization.
An in parameter of an access type lends the subprogram what it designates (an observer for a function, a borrower that may change the designated object for a procedure), while the caller remains its owner. Moving the parameter's value into another object would make a second owner, so it is not allowed.
Example (Vada)
procedure Keep (C : Cell; Into : out Cell) is
begin
Into := C; -- the caller still owns C's object
end Keep;Example (Varc)
fn keep(c: Cell, into: out Cell) {
into = c; // the caller still owns c's object
}
What to do (Vada)
Copy what you need (Into := new Integer'(C.all);), or make the parameter in out so that the subprogram can take the object over and give the caller something else (null).
What to do (Varc)
Copy what you need (into = new Integer(*c);), or make the parameter inout so that the subprogram can take the object over and give the caller something else (null).
Regression source and further reading
Complete regression example: source, command arguments and expected results. The fixture deliberately reproduces this diagnostic.
See ownership and finalization, the code index, and diagnostic interpretation for modes, replay, fix-its and JSON.