Credence.Semantic.NoCaptureAsBitwiseAnd (credence v0.8.0)

Copy Markdown

Repairs the common Python→Elixir translation error where & is written as the bitwise-AND operator.

In Python (and C) x & 1 means bitwise AND. In Elixir & is the capture operator, so x & 1 parses as x(&1) — a call passing capture argument &1 outside any &(...). The compiler rejects it with an :error-severity diagnostic:

capture argument &1 must be used within the capture operator &

whose {line, column} points straight at the &.

The code never compiles for any input, so this is a REPAIR: the fix rewrites the offending IDENT & <integer> to the idiomatic, fully-qualified Bitwise.band(IDENT, <integer>) (no import needed). It is targeted by the diagnostic column, so only that one operator changes — never a legitimate capture elsewhere on the line (&foo/1, &(&1 + 1)).