Credence.Pattern.PreferSigilCharlist (credence v0.8.0)

Copy Markdown

Rewrites a single-quoted charlist literal 'abc' to the ~c"abc" sigil.

Single-quoted charlists are deprecated since Elixir 1.15 ("using single-quoted strings to represent charlists is deprecated") and become a hard error under --warnings-as-errors. LLMs emit them constantly when translating Python. 'abc' and ~c"abc" are the same value ([97, 98, 99]), so the rewrite is behaviour-identical — it only changes the source representation.

Bad

['1', 'abc']

Good

[~c"1", ~c"abc"]

Scope

Only non-interpolated single-quoted charlist literals are matched, detected precisely via Sourceror's delimiter: "'" metadata — so a ' inside a double-quoted string ("don't") or an existing ~c sigil is never touched. Interpolated charlists (a different AST shape) are left alone. Escaping (", \) in the result is handled by rendering the ~c"..." sigil through Sourceror.