DEVELOPMENT EDITION · 769442725406
Diagnostics Reference
On this page

B6003: parameter or global still moved at a return

Catalog status: active. Default severity: error. Stable name: moved-at-return. Family: Ownership and finalization.

When a subprogram returns, its in out and out parameters and the global objects it uses go back to their owners, who expect them to own whatever they designate. A part of such an object whose value was moved out (B6002) owns nothing any more, so it must get a new value before the subprogram returns.

Example (Vada)

   procedure Take (From : in out Cell; To : out Cell) is
   begin
      To := From;    --  From's object now belongs to To
   end Take;         --  From is still moved

Example (Varc)

    fn take(from: inout Cell, to: out Cell) {
        to = from;   // from's object now belongs to to
    }                // from is still moved

What to do (Vada)

Give the moved part a new value before returning: From := null; hands back an empty owner, or assign it the object it should own.

What to do (Varc)

Give the moved part a new value before returning: from = null; hands back an empty owner, or assign it the object it should own.

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.