Skip to content

fix: don't crash on charlist with pure interpolation#133

Open
moxley wants to merge 1 commit into
elixir-tools:mainfrom
moxley:fix-list-string-pure-interpolation
Open

fix: don't crash on charlist with pure interpolation#133
moxley wants to merge 1 commit into
elixir-tools:mainfrom
moxley:fix-list-string-pure-interpolation

Conversation

@moxley
Copy link
Copy Markdown

@moxley moxley commented May 15, 2026

The :list_string non-interpolation clause of parse_string/1 was missing the when is_binary(string) guard that the parallel :bin_string clause has. When the tokenizer emits a single-element token list for a charlist that contains only an interpolation (e.g. '#{x}'), the unguarded clause matches and calls String.to_charlist/1 on the interpolation-segment tuple, raising FunctionClauseError.

Charlists with surrounding text ('foo#{x}bar') were unaffected because their token list has multiple elements and falls through to the interpolation-aware clause.

Fixes #132

The :list_string non-interpolation clause of parse_string/1 was missing
the `when is_binary(string)` guard that the parallel :bin_string clause
has. When the tokenizer emits a single-element token list for a charlist
that contains only an interpolation (e.g. '#{x}'), the unguarded clause
matches and calls String.to_charlist/1 on the interpolation-segment
tuple, raising FunctionClauseError.

Charlists with surrounding text ('foo#{x}bar') were unaffected because
their token list has multiple elements and falls through to the
interpolation-aware clause.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parser crashes on charlist with pure interpolation ('#{x}')

1 participant