menu

ambiguous-precedence

Require grouping where operator precedence is easy to misread

Mixed arithmetic, shift, bitwise, comparison, and logical operators can make evaluation order difficult to see. Instead, you SHOULD parenthesize each nested operation whose precedence is not conventional arithmetic.

Reported

1function mask(offset: int64, width: int64): int64 {2    return 1 << offset + width;3}

Accepted

1function mask(offset: int64, width: int64): int64 {2    return 1 << (offset + width);3}