Skip to content

[5.9]Fixes wrong escape when creating a string literal where a pound sign follows a sequence of double quotes or backslashes #1821

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

Merged
merged 2 commits into from
Jun 20, 2023

Conversation

kishikawakatsumi
Copy link
Contributor

@kishikawakatsumi kishikawakatsumi commented Jun 20, 2023


The following pull request changes will also be merged into the release/5.9 branch.

#1813

This pull request fixes a problem where escaping fails when a pound sign follows a sequence of double quotes or backslashes.

As shown in the added test case, foobar""# and foobar\# require two pound signs as delimiter for escaping, but the current implementation only adds one pound sign, resulting in an incorrect string literal.

The reason for this is that a sequence of double quotes or backslashes will stop counting pound signs if they are not followed by a pound sign.

If a double quotation mark or backslash is followed by a double quotation mark or backslash, it must continue in pound sign counting mode.

…follows a sequence of double quotes or backslashes.

This pull request fixes a problem where escaping fails when a pound sign follows a sequence of double quotes or backslashes.

As shown in the added test case, `foobar""#` and `foobar\\#` require two pound signs as delimiter for escaping, but the current implementation only adds one pound sign, resulting in an incorrect string literal.

The reason for this is that a sequence of double quotes or backslashes will stop counting pound signs if they are not followed by a pound sign.

If a double quotation mark or backslash is followed by a double quotation mark or backslash, it must continue in pound sign counting mode.
@ahoppen
Copy link
Member

ahoppen commented Jun 20, 2023

@swift-ci Please test

@ahoppen ahoppen merged commit c89ea14 into swiftlang:release/5.9 Jun 20, 2023
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.

3 participants