Mutable binding never reassigned
a var that is never changed
var x = 10
print(x)let x = 10
print(x)Why
A var binding is never mutated after initialization. Use let to signal immutability to readers and the compiler.
The practice it serves
Spelling that hides what the code means. Family: W. Ownership, lending and moves.
Not flagged
A near miss: close to the pattern, but not it.
var x = 10
x += 1
print(x)Turn it off
For one block, wrap it in with lint(var_never_reassigned: allow):. For a project, add var_never_reassigned = "allow" under [lints] in cp.toml.
Generated from spec/lints/var_never_reassigned, the same record the linter is built from.