[5.9]Fixes wrong escape when creating a string literal where a pound sign follows a sequence of double quotes or backslashes #1821
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.
StringLiteralExprSyntax(content:)
constructed an invalid string literal whencontent
contained a pound sign follows a sequence of double quotes or backslashes.StringLiteralExprSyntax(content:)
initializerThe 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.