-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Change diagnostic error thrown for when string interpolations aren't closed by a parenthesis #58882
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
Merged
AnthonyLatsis
merged 49 commits into
swiftlang:main
from
NSAntoine:serena/interpolation-and-unterminated-string-notes
Jun 4, 2022
Merged
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
b0e552d
Change error diagnosed when a string interpolation isnt closed
NSAntoine ec4f51c
change string_interpolation_unclosed to sound more natural
NSAntoine 719fe1e
(potentionally) fix test errors
NSAntoine e8aad99
ACTUALLY fix tests, revert last commit
NSAntoine 4e41d38
Add note and fix-it for string interpolation not ended with a )
NSAntoine 6ab71cb
im dumb and forgot to remove this semicolon
NSAntoine e57780f
fix tests..again..
NSAntoine 97b23c7
fix tests
NSAntoine 03b2c4e
oops, i did not mean to push that yet
NSAntoine 572177c
Fix fix-it for fixing unclosed string interpolation being given for a…
NSAntoine ec17988
try different approach
NSAntoine dabfdc0
Cast to char * to fix compilation error
NSAntoine 4ca418a
change declaration of fixItLoc
NSAntoine 95ca0b8
Remove string interpolation fix-it note, now instead attach the fix-i…
NSAntoine b93a70d
add this back to reflect previous change
NSAntoine 4ef5c99
Trigger string_interpolation_unclosed only when CurPtr ends in a \r o…
NSAntoine e2626ee
fix indentation
NSAntoine c47deb5
remove fix-it
NSAntoine 87acdff
Change string_interpolation_unclosed to be diagnosed with CurPtr, add…
NSAntoine 1614242
Add note & tests requested
NSAntoine 95e2730
Update lib/Parse/Lexer.cpp
NSAntoine bc58ed9
remove unused note
NSAntoine 8523850
Merge branch 'serena/interpolation-and-unterminated-string-notes' of …
NSAntoine f34cfd9
this is what a day of no sleep does to a person
NSAntoine 7121a5b
diagnose lex_unterminated_string for when CurPtr isnt )
NSAntoine a431b20
don't diagnose lex_unterminated_string when string literal is multili…
NSAntoine 9dff8c8
im dumb
NSAntoine 3acf0d4
changes
NSAntoine bcfdbac
emit diag::lex_unterminated_string as a fallback, and some other stuff
NSAntoine 8a2cb84
add back some more comments, remove some useless stuff
NSAntoine 76d4448
Check for if CurPtr is BufferEnd when checking for if CurPtr is \n or \r
NSAntoine 787fb1a
Add back `continue` statement and correct grammar
NSAntoine 68a7549
Don't drefrence CurPtr when comparing to BufferEnd
NSAntoine 2dc8cbb
how did i forget this
NSAntoine caeffb9
shouldn't have been there
NSAntoine 1616a5c
This should be correct now..
NSAntoine 7e640b1
this isn't needed apperantly
NSAntoine 152bf41
Refactor position when diagnosing lex_unterminated_string
NSAntoine 045abec
Restructure handling when string interpolation isn't ended by a paren…
NSAntoine bb91faa
Correct indentation
NSAntoine 35a7008
fix indentation.. again..
NSAntoine 27a6f95
Fix tests and add one more test
NSAntoine 0df097d
move test to end of file
NSAntoine 5925ea5
Fix tests finally.. maybe..
NSAntoine 5e1d60c
Point to --TmpPtr instead
NSAntoine ec37cc9
Stop diagnosing opening_paren when diagnosing string_interpolation_un…
NSAntoine e27e78e
Fixes
NSAntoine be472ed
revert unneeded changes made by previous commit
NSAntoine 61c4a8c
change message of string_interpolation_unclosed
NSAntoine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// NOTE: DO NOT add a newline at EOF. | ||
// expected-error@+1 {{unterminated string literal}} | ||
// expected-error@+2 {{unterminated string literal}} | ||
// expected-error@+1 {{expected ')' at end of string interpolation}} expected-note @+1 {{to match this opening '('}} | ||
_ = "foo\( |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// NOTE: DO NOT add a newline at EOF. | ||
// expected-error@+2 {{expected ')' at end of string interpolation}} expected-note @+2 {{to match this opening '('}} | ||
// expected-error@+1 {{unterminated string literal}} | ||
_ = "foo\("bar |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// NOTE: DO NOT add a newline at EOF. | ||
// expected-error@+1 {{unterminated string literal}} | ||
// expected-error@+2 {{unterminated string literal}} | ||
// expected-error@+3 {{expected ')' at end of string interpolation}} expected-note @+3 {{to match this opening '('}} | ||
_ = """ | ||
foo | ||
\( |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
// NOTE: DO NOT add a newline at EOF. | ||
// expected-error@+1 {{unterminated string literal}} | ||
// expected-error@+2 {{unterminated string literal}} | ||
// expected-error@+3 {{expected ')' at end of string interpolation}} expected-note @+3 {{to match this opening '('}} | ||
_ = """ | ||
foo | ||
\("bar |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// RUN: %target-typecheck-verify-swift | ||
|
||
let mid = "pete" | ||
|
||
_ = "mid == \(pete" | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
|
||
let theGoat = "kanye \(" | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
|
||
let equation1 = "2 + 2 = \(2 + 2" | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
|
||
_ = """ | ||
\( | ||
""" | ||
// expected-error @-2 {{expected ')' at end of string interpolation}} expected-note @-2 {{to match this opening '('}} | ||
|
||
let s = "\(x"; print(x) | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
|
||
let zzz = "\(x; print(x) | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
|
||
let goatedAlbum = "The Life Of \("Pablo" | ||
// expected-error @-1 {{expected ')' at end of string interpolation}} expected-note @-1 {{to match this opening '('}} | ||
// expected-error @-1 {{unterminated string literal}} |
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
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.
Uh oh!
There was an error while loading. Please reload this page.