E1086: value cannot be indexed

View source

Only an Array and a Buffer can be indexed with [...].

Only an Array and a Buffer can be indexed with [...]. A number, a struct or any other value has no slots to select. The message names the type of the value. The error points at the indexed expression.

Example

actus
verb main() {
    erg n: Int = 4;
    erg x = n[0];
}
actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: 1, };
    erg y = p[0];
}

Fix

Index an array or a buffer. Use a field name for a struct.

actus
verb main() {
    erg values: Array[Int, 4] = Array[Int, 4]();
    erg x = values[0];
}
actus
struct Point {
    x: Int,
}

verb main() {
    erg p: Point = Point { x: 1, };
    erg y = p.x;
}

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