E1011: move or mutate of a frozen binding

View source

An owner with a live abs view is frozen (ADR-0016).

An owner with a live abs view is frozen (ADR-0016). It may be read, but it cannot be assigned or moved until the view ends, because the view must keep seeing the same value. A view lives until the end of the block that holds it. The error points at the assignment or the move. A field of a frozen owner is reported as E1035.

Example

actus
verb main() {
    erg count: Int = 1;
    abs view = ref count;
    count = 2;
    println(int: view);
}
actus
verb main() {
    erg data: Buffer = Buffer[4];
    abs view = ref data;
    erg other = data;
    println(int: buffer_length(buffer: abs view));
}

A struct with an abs field freezes its source the same way, until the end of the block that builds the struct:

actus
struct Header {
    abs bytes: Buffer,
}

verb main() {
    erg data: Buffer = Buffer[4];
    erg header = Header { bytes: data, };
    erg other = data;
}

Fix

Change or move the owner when no view exists, either before the view is created or after the block that holds it.

actus
verb main() {
    erg count: Int = 1;
    count = 2;
    abs view = ref count;
    println(int: view);
}
actus
verb main() {
    erg data: Buffer = Buffer[4];
    {
        abs view = ref data;
        println(int: buffer_length(buffer: abs view));
    }
    erg other = data;
}

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