st1018: don't suggest escape sequences inside raw string literals - #1731
Draft
Eljees wants to merge 1 commit into
Draft
st1018: don't suggest escape sequences inside raw string literals#1731Eljees wants to merge 1 commit into
Eljees wants to merge 1 commit into
Conversation
Author
|
Marking this ready for review. I'd been holding it as a draft while #1730 was open, in case you'd rather take contributions one at a time — say the word and I'll close one. A draft doesn't show up in your review queue at all, though, so leaving it that way seemed worse than asking. |
Owner
|
Thanks, I'll take a look eventually. |
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.
Fixes #1115.
Escape sequences are not interpreted inside raw string literals, so replacing an invisible character there with its escape sequence changes the string's value to the six literal characters of that sequence rather than removing the invisible one. The current testdata golden file records exactly that: the
e = ...line holds a raw literal whose zero-width space has been "replaced" by six visible characters.The message has the same problem: it tells the user to use an escape sequence that would not work where they are.
For raw string literals this now offers only the deletion fix, and the message points at an interpreted string literal instead. On a file with the same zero-width space in both kinds of literal:
The golden file loses its
replace format character U+200B with ...section, which the test flags on its own: without that removal,TestTestdatafails with "golden has section for suggested fix ..., but we didn't produce any fix by that name".I did not add testdata rows for a raw literal holding several invisible characters, since every added line rewrites all eight golden sections; happy to do it if you'd rather have the coverage.
(Edited: the first version of this description contained literal zero-width characters in the places where the escape sequence was meant to be shown, which rather made the point.)