Don't treat continuation tokens of interpolated sigils as sigils#40
Merged
josevalim merged 1 commit intoJul 9, 2026
Merged
Conversation
A sigil containing interpolation is split into multiple :string_sigil
tokens, one before and one after each interpolation. The custom sigil
lexer postprocessing matched any :string_sigil token and read the
element at index 1 to look up a registered sigil lexer, so a
continuation token whose second element happened to be a registered
sigil character (for example the H in the /HEAD" chunk of
~w"refs/remotes/#{remote}/HEAD", with makeup_eex registering ~H)
crashed with a MatchError when asserting the token starts with "~".
Only apply custom sigil lexers to tokens that start with "~" and let
continuation tokens fall through to the catch-all clause.
Collaborator
|
💚 💙 💜 💛 ❤️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A sigil containing interpolation is split into multiple
:string_sigiltokens, one chunk before and one after each interpolation. The custom sigil lexer postprocessing matches any:string_sigiltoken, reads the element at index 1 to look up a registered sigil lexer, and then asserts the token starts with"~"— which only holds for the opening chunk.If the element at index 1 of a later chunk happens to be a registered sigil character, the lookup succeeds and the assertion crashes with a
MatchError. This happens in the wild: with makeup_eex registering a lexer for~H, lexing credo'sfirst_run_hint.excrashes on~w"symbolic-ref refs/remotes/#{remote_name}/HEAD"because the chunk after the interpolation is
/HEAD", whose element at index 1 isH:The custom sigil clause now only matches tokens that start with
"~", so continuation chunks fall through to the catch-all clause and are kept as plain sigil content.