E1021: invalid argument for a built-in intrinsic

View source

Built-in intrinsics such as buffer_length, crc32 and copy check their arguments more strictly than ordinary verbs.

Built-in intrinsics such as buffer_length, crc32 and copy check their arguments more strictly than ordinary verbs. The buffer must be a readable Buffer, ranges and sizes must be integers, and copy accepts only a scalar (Int, Bool, an integer or a float type; ADR-0059, ADR-0126) or a struct, an enum or a pack declared meta copy, or an Array whose element type is itself a copy type (ADR-0124). The message names the intrinsic and the parameter. The error points at the argument.

A console call names the kind of its value with a label: println(int: n), println(string: s), println(bool: f) or println(buffer: b). println(x) and eprintln(x) without a label are rejected with this error. The message names the form to write, with the label of the type of x (ADR-0084), and the error points at the whole call.

Example

actus
verb main() {
    erg n: Int = 4;
    println(int: buffer_length(buffer: abs n));
}
actus
verb main() {
    erg data: Buffer = Buffer[4];
    erg copied = copy(value: abs data);
}
actus
struct Plain {
    value: Int,
}

verb main() {
    erg plain = Plain { value: 1, };
    erg copied = copy(value: abs plain);
}
actus
verb main() {
    erg slots: Array[Buffer, 2] = Array[Buffer, 2]();
    erg copied: Array[Buffer, 2] = copy(value: abs slots);
}
actus
verb main() {
    erg n: Int = 4;
    println(n);
}

Fix

Pass a value of the type that the parameter needs. actus fix writes the label of an unlabelled println or eprintln call. A buffer cannot be copied, so when a second owner is needed, move the first one. A struct, an enum or a pack of plain data can declare meta copy to be copied.

actus
verb main() {
    erg data: Buffer = Buffer[4];
    println(int: buffer_length(buffer: abs data));
}
actus
verb main() {
    erg data: Buffer = Buffer[4];
    erg moved = data;
}
actus
meta copy
struct Plain {
    value: Int,
}

verb main() {
    erg plain = Plain { value: 1, };
    erg copied = copy(value: abs plain);
}
actus
verb main() {
    erg values: Array[Int, 3] = Array[Int, 3]();
    erg copied: Array[Int, 3] = copy(value: abs values);
}
actus
verb main() {
    erg n: Int = 4;
    println(int: n);
}

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