E1079: arena moved or dropped while a reference is live
A reference into an arena is only valid while the arena exists, so the arena may not be moved, dropped, or overwritten while a live abs or ins binding refers to one of its value...
A reference into an arena is only valid while the arena exists, so the arena
may not be moved, dropped, or overwritten while a live abs or ins binding
refers to one of its values (ADR-0030). Every way of giving the arena up counts:
drop(arena), a dat argument, erg other = arena, an assignment from or to
the arena, and a struct field that takes it, whether the field is erg or has
no role. The message names the arena and
the reference. The error points at the move or the drop.
A view lives until the end of the block that holds it, as for E1011, so a view
in a block that has already ended does not block the release. A value that was
placed in the arena is not a view, so it does not block the release either, but
it may not be read once the arena is gone. That read is the same error, and it
points at the read.
Example
A struct field moves the arena the same way. A field of an arena type is
declared erg (E1148):
A struct that holds an arena is the arena's owner (ADR-0130), so the rule
applies to the holder: a value placed through it, place(arena: ins holder.held, ...), has
the holder as its owner. While a view of such a value is live, the holder cannot
be dropped, moved, assigned to, given to a dat parameter, or have its arena
field moved out, and the message names the holder:
A placed value that is not a view may not be read once the holder is gone:
A placed value is only readable while an owner of its arena is still in scope.
Here the new owner ends with its block, so the read of node fails:
Fix
Finish with the values first, and create no view of them that is still live when the arena is moved or dropped. Keep a view in its own block so that it ends before the arena is released. An arena that is not dropped explicitly is released when its scope ends.
A holder is released the same way once its views have ended, and an arena that moved into a holder leaves its placed values readable through the holder:
Run actus explain E1079 in your terminal to read this entry offline. Browse Ownership & types or all error codes.