E1151: local binding declared with the `ins` role

View source

ins is an instrument lent for one call (ADR-0020, REQ-VIEW-0090).

ins is an instrument lent for one call (ADR-0020, REQ-VIEW-0090). It is valid on a verb parameter and as the role of a call-site argument, where the loan begins and ends with the call. A local binding outlives any one call, so it cannot be a loan: declare it erg, and lend it with ins at the call that needs to change it. The message names the binding and the role. The error points at the declaration.

Example

actus
verb main() -> Int {
    ins value: Int = 0;
    return value;
}
actus
struct Node {
    value: Int,
}

verb main() -> Int {
    erg arena: Arena[128] = Arena[128]();
    ins node = place(arena: ins arena, value: Node { value: 1, });
    return 0;
}

Fix

Declare the binding with erg.

actus check --format json offers this as a safe fix: it replaces the ins keyword by erg and, at every call in the binding's scope that passed it to an ins parameter with no role (the calls that relied on the old inference of an ins local), writes ins before the argument, so the fixed program checks without a second round. actus fix applies it.

actus
verb main() -> Int {
    erg value: Int = 0;
    return value;
}
actus
verb bump(ins value: Int) {
    value += 1;
}

verb main() -> Int {
    erg value: Int = 0;
    bump(value: ins value);
    return value;
}

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