E1078: value mixes two arenas

View source

Every value that is placed in an arena remembers which arena it came from (ADR-0030).

Every value that is placed in an arena remembers which arena it came from (ADR-0030). A reference into one arena cannot be placed into another arena or combined with a value from another arena, because the first arena may be released while the second one still holds the reference. The error points at the value. The message names the value that is being placed, such as the binding a.

Example

actus
struct Node {
    value: Int,
}

verb main() {
    erg first: Arena[64] = Arena[64]();
    erg second: Arena[64] = Arena[64]();
    erg a = place(arena: ins first, value: Node { value: 1, });
    erg b = place(arena: ins second, value: a);
}

Fix

Place values that belong together in the same arena.

actus
struct Node {
    value: Int,
}

verb main() {
    erg first: Arena[64] = Arena[64]();
    erg a = place(arena: ins first, value: Node { value: 1, });
    erg b = place(arena: ins first, value: Node { value: 2, });
}

Run actus explain E1078 in your terminal to read this entry offline. Browse Ownership & types or all error codes.