E1034: field assigned through a view

View source

A field can be assigned only through an owner that may change it: an erg binding, or an ins loan that the caller lent for the call.

A field can be assigned only through an owner that may change it: an erg binding, or an ins loan that the caller lent for the call. An abs binding is a read-only view (ADR-0016), so assigning to its fields is rejected. A field of something that is not a binding, such as the result of a call, has no owner to assign through. The error points at the assignment.

Example

actus
struct Point {
    x: Int,
}

verb show(abs p: Point) {
    p.x = 2;
}

verb main() {
}

Fix

Declare the parameter ins when the verb must change the caller's value.

actus
struct Point {
    x: Int,
}

verb show(ins p: Point) {
    p.x = 2;
}

verb main() {
}

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