Repository navigation
Read an interpolation format specifier as text, not code [patch] - #168
Merged
matt-edmondson merged 1 commit intoNov 4, 2026
Merged
Conversation
VerbatimStringScanner walked everything inside an interpolation hole as
code, so the `//` in `{d:yyyy//MM}` started a line comment that swallowed
the hole's closing brace and the string's closing quote. An expression
body then got its semicolon inside a trailing comment (CS1002), and a
verbatim string's continuation lines were re-indented.
A colon outside every nested parenthesis, bracket and brace in a hole,
and not part of a `::` alias qualifier, now starts the format specifier,
which is skipped as literal text up to the hole's closing brace.
Fixes #165
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW3PT52Zo3M7fFP8Z6J
|
matt-edmondson
deleted the
claude/issue-165-format-specifier-not-comment
branch
November 4, 2026 00:55
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 #165
Summary
VerbatimStringScannertreated everything inside an interpolation hole as code. So the//in{d:yyyy//MM}started a line comment, and that comment swallowed the hole's}and the string's closing". Both fixes that rely on the scanner then went wrong:public int P => x // note;does not compile (CS1002) #144:$"{d:yyyy//MM}" // cas an expression body rendered as… // c;, which fails with CS1002.$@"{d:yyyy//MM}verbatim string spanning two lines, the continuation line was re-indented, which changes the string's value.The fix is in
ScanCode. While inside a hole, it now tracks(/[depth alongside the existing{depth. A:at depth 0 starts the format specifier, provided it is not part of a::alias qualifier. The format specifier is skipped as literal text up to the hole's closing}. A conditional? :and a named argument are always nested inside parentheses, so their colons are not mistaken for one.SkipInterpolationHolenow consumes the next character only when it really is a}, so a malformed fragment cannot have a line break eaten.Tests
mainand pass with the fix (checked by reverting the scanner and running again):global::qualifier (TemplateTests)TemplateTests)SplitLinesrow with//in a format specifiermainand still pass:public int P => x // note;does not compile (CS1002) #144 tests still pass. Full suite: 256/256.Generated by Claude Code