E1094: struct field cannot hold an ins loan

View source

An ins loan lasts for one call (ADR-0020).

An ins loan lasts for one call (ADR-0020). A struct field would keep the loan for as long as the struct lives, which no call boundary could end, so Alpha rejects ins fields (ADR-0046). A field is a plain value field, or an erg field that owns its value, or an abs field that holds a view. The message names the field, the struct and the role. The error points at the field.

Example

actus
struct Holder {
    ins buf: Buffer,
}

verb main() {
}

Fix

Make the struct own the value with an erg field, and pass the struct to a verb with an ins parameter when a call needs to change it.

actus
struct Holder {
    erg buf: Buffer,
}

verb main() {
}

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