← All lints

missing_parens

L0608Stylewarn

Work without parentheses

xs.sum: a member that does work takes ()

Flagged
let xs = [1, 2, 3]
print(xs.sum)
Write instead
let xs = [1, 2, 3]
print(xs.sum())

Why

Parentheses mark work in CP Lang (decision 140): xs.sum(), xs.sorted() and g.transpose() walk or allocate, so they take (), and anything read without () is O(1)O(1). Writing xs.sum hides a loop behind field syntax; xs.sum() shows the cost where it is paid.

The practice it serves

Spelling that hides what the code means.

Not flagged

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

Near miss
let xs = [1, 2, 3]
print(xs.len)

Turn it off

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

Generated from spec/checker-lints/missing_parens, the same record the linter is built from.