# `MutagenEx.Mutators.Literal`
[🔗](https://github.com/iautom8things/mutagen_ex/blob/v0.2.0/lib/mutagen_ex/mutators/literal.ex#L1)

Flips `true ↔ false` and swaps small integer literals: `0 ↔ 1`, `1 ↔ 0`,
`-1 → 1`.

Per `mutagen.mutators` catalog entry 4.

The boolean flip is fully symmetric.

The integer rewrite is restricted to the literals `0`, `1`, and `-1` so
the swap stays within "small integer" territory and so reversibility is
well-defined:

  * `0 → 1`
  * `1 → 0`
  * `-1 → 1`

Wider integers are intentionally out of scope: the catalog is closed in
v1 (`mutagen.mutators.r7`), and adding configurable integer pools would
cross that line.

## AST shapes (bw mutagen-wrd.15)

`mix mutagen` parses source with `Code.string_to_quoted(..., token_metadata:
true, columns: true)` (see `lib/mutagen_ex/ast_cache.ex`). Atomic literals
appear in the parsed AST in **two** shapes that the enumerator's
`Macro.prewalk/3` traversal can visit:

  1. **Bare** — the literal stands alone as a child of an operator, case
     clause head, etc. (e.g., the `0` in `{:>, _, [n, 0]}` or the `1` in
     `{:->, _, [[1], :one]}`). The bare child carries no metadata of its
     own; it is matched here by the unwrapped clauses.
  2. **`__block__`-wrapped** — the parser wraps a literal in a metadata-
     carrying `{:__block__, meta, [value]}` 3-tuple when it needs to
     attach token / line / column info to the literal directly. The
     enumerator's `node_line/1` extracts the line from the wrapper's
     `meta`; an unwrapped match would lose that line and the enumerator
     would drop the site when no parent supplies a line.

Both shapes match; mutating a `__block__`-wrapped literal preserves the
wrapper (and therefore the line/column metadata) so the rewritten AST is
also a 3-tuple the enumerator can attribute to a source line.

Site identity keeps the distinction between a bare literal and a
`__block__` wrapper. Position and token metadata on the wrapper are
ignored by mutation ID scheme 2.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
