Lyricdev
GitHub

LYR-PAR0043

an inline array of no positive literal length

error ยท spec 03-types

An inline array type T[n] gives a length that is not a positive decimal literal: int[0], int[0x4].

Explanation

T[n] is a value of exactly n elements, held inline. Its length is a positive decimal literal; a length of zero holds nothing, and a constant or a parameter as a length is not part of the language.

Write the length as a positive decimal number, or use T[] for an array whose length is known at run time.

Wrong

fn sum(xs: int[0]): int {
    return 0;
}

fn main(): void {
}
fn sum(xs: int[3]): int {
    return xs[0] + xs[1] + xs[2];
}

fn main(): void {
    let _ = sum;
}