Skip to content

Do not lex a verbatim string as a raw string - #772

Merged
SimonCropp merged 2 commits into
mainfrom
fix-cs-lexer-verbatim-quote-run
Aug 21, 2026
Merged

Do not lex a verbatim string as a raw string#772
SimonCropp merged 2 commits into
mainfrom
fix-cs-lexer-verbatim-quote-run

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

TrySkipStringLike measured the quote run before checking whether the literal was verbatim, so a verbatim string opening on an escaped quote came out as a 3-quote raw string. There is no verbatim raw form: after @" a run of quotes is content.

The consequence was not a mis-parse of that one literal. A raw string ends at the next run of at least as many quotes, and there is none, so the scan ran to the end of the file and every Snapshot call below the line disappeared. A test file with a Windows path in a verbatim string above its snapshots could not have any of them patched, reporting only "Could not find a Snapshot call near line N".

CsStringLiteral.TryScan and FsLanguage both ask this question before measuring, and say why in a comment; the lexer was the one place that did not.

TrySkipStringLike measured the quote run before checking whether the literal was
verbatim, so a verbatim string opening on an escaped quote came out as a 3-quote
raw string. There is no verbatim raw form: after @" a run of quotes is content.

The consequence was not a mis-parse of that one literal. A raw string ends at
the next run of at least as many quotes, and there is none, so the scan ran to
the end of the file and every Snapshot call below the line disappeared. A test
file with a Windows path in a verbatim string above its snapshots could not have
any of them patched, reporting only "Could not find a Snapshot call near line N".

CsStringLiteral.TryScan and FsLanguage both ask this question before measuring,
and say why in a comment; the lexer was the one place that did not.
@SimonCropp
SimonCropp merged commit 9319ae8 into main Aug 21, 2026
8 checks passed
@SimonCropp
SimonCropp deleted the fix-cs-lexer-verbatim-quote-run branch August 21, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant