E1148: struct field of an arena type that is not `erg`

View source

A struct that holds an arena owns it, as a struct that holds a Buffer owns the buffer (ADR-0130).

A struct that holds an arena owns it, as a struct that holds a Buffer owns the buffer (ADR-0130). The field that holds the arena is therefore declared erg: a field with no role, or an abs field, would leave the ownership of the arena unstated, and a view of an arena cannot place into it. An ins field stays the error it always was (E1094), and a meta copy struct with an arena field is E1146, because an arena cannot be copied. The message names the field and the struct, and the error points at the field.

Example

actus
struct Scene {
    nodes: Arena[64],
}

verb main() {
}
actus
struct Scene {
    abs nodes: Arena[64],
}

verb main() {
}

Fix

Declare the field erg. The struct then owns the arena and places into it through the field.

actus
struct Node {
    value: Int,
}

struct Scene {
    erg nodes: Arena[64],
}

verb main() -> Int {
    erg scene = Scene { nodes: Arena[64](), };
    erg node = place(arena: ins scene.nodes, value: Node { value: 1, });
    return node.value;
}

Run actus explain E1148 in your terminal to read this entry offline. Browse Modules & rules or all error codes.