Lyricdev
GitHub

LYR-SEM0228

an inline array of another length

error ยท spec 03-types

An array literal or a repetition [x] * n that is to be an inline array T[N] makes another number of elements than N.

Explanation

An inline array holds exactly its length: int[3] is three ints, inline. A literal for it writes each of them, a repetition makes as many as it says; another count is no value of the type.

Write N elements, or the length the elements have.

Wrong

fn main(): void {
    let cells: int[3] = [1, 2];
    let _ = cells;
}
fn main(): void {
    let cells: int[3] = [1, 2, 3];
    let _ = cells;
}