Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiline string interpolation when preceded by a " character #1023

Merged
merged 2 commits into from
Jan 2, 2023

Conversation

matthew-healy
Copy link
Contributor

Due to an issue with the Logos parser generator, we have a special rule
which looks for a " followed by some number of %s and then splits
the token into one "%+ token and an interpolation token.

When symbolic strings were introduced, we changed how the lexer counts
its opening %s, to no longer consider the m or s character as part
of the token. However, we did not update the condition for the rule to
patch over the Logos issue. This essentially meant that we would
introduce an interpolation after a " with one too-few opening %
characters.

This PR fixes that behaviour by changing the >= check to a >.

I also took the opportunity to restructure the string test files.

Closes #1012.

Due to an issue with the Logos parser generator, we have a special rule
which looks for a `"` followed by some number of `%`s and then splits
the token into one `"%+` token and an interpolation token.

When symbolic strings were introduced, we changed how the lexer counts
its opening `%`s, to no longer consider the `m` or `s` character as part
of the token. However, we did not update the condition for the rule to
patch over the Logos issue. This essentially meant that we would
introduce an interpolation after a `"` with one too-few opening `%`
characters.

This commit fixes that behaviour by changing the `>=` check to a `>`.
@matthew-healy matthew-healy marked this pull request as ready for review December 30, 2022 11:10
@github-actions github-actions bot temporarily deployed to pull request December 30, 2022 11:12 Inactive
@github-actions github-actions bot temporarily deployed to pull request December 30, 2022 13:06 Inactive
@matthew-healy matthew-healy merged commit 3417bc2 into master Jan 2, 2023
@matthew-healy matthew-healy deleted the fix/multiline-interpolation branch January 2, 2023 09:56
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.

Incorrect interpretation of interpolation sequence in multiline strings
2 participants