E1095: assignment to an abs struct field

View source

An abs field holds a read-only view that the struct does not own (ADR-0046).

An abs field holds a read-only view that the struct does not own (ADR-0046). It is set when the struct is built and then only read, so assigning to it later is rejected. The message names the field and the struct. The error points at the assignment.

Example

actus
struct Holder {
    abs payload: Buffer,
}

verb main() {
    erg buffer: Buffer = Buffer[4];
    erg other: Buffer = Buffer[8];
    erg holder: Holder = Holder { payload: buffer, };
    holder.payload = other;
}

Fix

Declare the field erg, or without a role, when it must change.

actus
struct Counter {
    erg total: Int,
}

verb main() {
    erg c: Counter = Counter { total: 1, };
    c.total = 2;
}

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