-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parse] Fix skipping string interpolation in Lexer #10246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Parse] Fix skipping string interpolation in Lexer #10246
Conversation
@swift-ci Please smoke test |
a140fcb
to
3fb3789
Compare
@swift-ci Please smoke test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
lib/Parse/Lexer.cpp
Outdated
@@ -1244,6 +1244,9 @@ static const char *skipToEndOfInterpolatedExpression(const char *CurPtr, | |||
DiagnosticEngine *Diags, | |||
bool MultilineString) { | |||
llvm::SmallVector<char, 4> OpenDelimiters; | |||
llvm::SmallVector<bool, 3> AllowNewline; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor nitpick: why 3? Might as well go with 4 or 8, as the small vector will be pointer-size aligned. This doesn't block this PR, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought was: if size of OpenDelimiters
is 4, size of AllowNewline
is at most 3.
str = "a\( "b\( "c\( something )")")"
" ( " ( -> OpenDelimiters : {'"', '(', '"', '('}
f f f -> AllowNewline : {false, false, false}
That was unnecessary restriction though. Updated to 4
.
Maintain inner most string literal mode to determine whether we allow newline character or not. * Disallow newline after multiline string in string interpolation. (SR-5171) * Allow unbalanced `"` in multiline string in string interpolation.
3fb3789
to
c8bd1aa
Compare
Thanks! |
@swift-ci Please smoke test and merge |
Maintain inner most string literal mode to determine whether we allow
newline character or not.
Disallow newline after multiline string in string interpolation. (SR-5171)
Allow unbalanced
"
in multiline string in string interpolation.