Fix escaping problem in write_literal
and print_literal
lint suggestion
#13990
+137
−3
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.
fix #13959
The current implementation of the
write_literal
andprint_literal
lint performs escaping for the second argument ofwrite!
,writeln!
,print!
andprintln!
of the suggestion by first replacing"
with\"
, and then replacing\
with\\
. Performing these replacements in this order may lead to unnecessary backslashes being added if the original code contains"
(e.g."
->\\"
), potentially resulting in a suggestion that causes the code to fail to compile.In the issue mentioned above, it’s suggested to use raw strings as raw strings, but implementing this would require an ad-hoc change to the current implementation, so it has been deferred. (I'll implement this in another PR)
changelog: [
write_literal
]: fix incorrect escaping of suggestionschangelog: [
print_literal
]: fix incorrect escaping of suggestions