Lyricdev
GitHub

LYR-RT0007

an argument that breaks a precondition

panic ยท spec 03-types

A length or count from the program text is negative: the count of [x] * n, the count of a string's repetition, the length of a new array or string. The standard library's own precondition checks (a negative capacity, a radix outside 2 to 36, a bad format string) panic with LYR-RT0008 instead.

Program

fn make(n: int): int[] {
    return [0] * n;
}

fn main(): void {
    assert(make(-1).length() == 0);
}