Discarded function return value
let _ = throws away what a fn of this file returns
fn work(u: Int) -> Int:
print(u)
u
let _ = work(2)fn work(u: Int):
print(u)
work(2)Why
Binding the result of a local function to let _ = hides intent. Either use the returned value or change the function to return nothing when it is only called for side effects.
The practice it serves
A hand-written pattern the language or the standard library already says in one step. Family: F. Functions, closures and generators.
Not flagged
A near miss: close to the pattern, but not it.
fn work(u: Int) -> Int:
print(u)
u
print(work(2))Turn it off
For one block, wrap it in with lint(discarded_result: allow):. For a project, add discarded_result = "allow" under [lints] in cp.toml.
Generated from spec/lints/discarded_result, the same record the linter is built from.