← All lints

pow_method

L0205Stylewarn

Power written with .pow(e)

a.pow(e): power is written a ** e

Flagged
let x = 2
print(x.pow(10))
Write instead
let x = 2
print(x ** 10)

Why

CP Lang spells exponentiation with ** on numbers, Mod<P>, Mat<T>, and any type implementing Pow. cpl fix rewrites a.pow(e) to a ** e.

The practice it serves

Spelling that hides what the code means. Family: S.math.

Not flagged

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

Near miss
let x = 2
print(x ** 10)

Turn it off

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

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