← All lints

redundant_arg_name

L0209Stylewarn

Named argument or record field repeating its own name

f(moves: moves) or (val: val) can be punned as f(moves:) / (val:)

Flagged
fn f(moves: Int, cost: Int) -> Int = moves + cost
let moves = 3
let cost = 4
print(f(moves: moves, cost: cost))
Write instead
fn f(moves: Int, cost: Int) -> Int = moves + cost
let moves = 3
let cost = 4
print(f(moves:, cost:))

Why

When a named call argument or record field passes a variable of the same name, write name: instead of name: name. cpl fix shortens name: name to name:.

The practice it serves

Spelling that hides what the code means. Family: F. Functions, closures and generators.

Not flagged

A near miss: close to the pattern, but not it.

Near miss
fn f(moves: Int, cost: Int) -> Int = moves + cost
let m = 3
print(f(moves: m, cost: 4))

Turn it off

For one block, wrap it in with lint(redundant_arg_name: allow):. For a project, add redundant_arg_name = "allow" under [lints] in cp.toml.

Generated from spec/lints/redundant_arg_name, the same record the linter is built from.