Lyricdev
GitHub

LYR-SEM0198

a parameter that is never used

warning · spec 07-statements · lint unused-parameter, group unused, warn unless said

A function's parameter is never named in its body. A method of a type with a conformance list, and a parameter whose name begins with _, are not reported.

Explanation

A parameter the body does not read asks every caller for a value nothing uses. It is often left over from a change, or a sign the body forgets something.

Take it out, use it, or name it _name where the signature is fixed and the value is deliberately ignored.

Wrong

fn twice(x: int, unused: int): int {
    return x * 2;
}

fn main(): void {
    let _ = twice(1, 2);
}
fn twice(x: int, _unused: int): int {
    return x * 2;
}

fn main(): void {
    let _ = twice(1, 2);
}