Lyricdev
GitHub

LYR-SEM0024

a variadic parameter out of place

error · spec 08-expressions

A variadic parameter name: T... is not the last parameter or has a default, or a parameter is written with Lyric 4's params.

Explanation

A variadic parameter takes all remaining arguments, so it stands last, and it has no default — given no arguments it is an empty array. Lyric 5 writes it nums: int...; params is the word of Lyric 4.

Move the variadic parameter to the end, drop its default, and write it with ....

Wrong

fn sum(nums: int..., scale: int): int { return nums.length() * scale; }

fn main(): void {
    let _ = sum;
}
fn sum(scale: int, nums: int...): int { return nums.length() * scale; }

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