E1004: borrow of a binding that is not an owner

View source

ref creates an abs view of an owner.

ref creates an abs view of an owner. ADR-0016 lets an erg owner or a received dat value create such a view. An abs parameter is already a view, and an ins parameter is a loan that lasts only for the call, so neither can be borrowed again. The error points at the declaration that holds the ref.

Example

actus
verb show(abs value: Int) {
    abs view = ref value;
}

verb main() {
    erg n: Int = 1;
    show(value: abs n);
}

Fix

Use the abs parameter directly. It is already a read-only view of the caller's value.

actus
verb show(abs value: Int) {
    println(int: value);
}

verb main() {
    erg n: Int = 1;
    show(value: abs n);
}

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