-
Notifications
You must be signed in to change notification settings - Fork 439
Fix diagnostic of ternary operator missing only colon #1677
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
ahoppen
merged 6 commits into
swiftlang:main
from
TTOzzi:fix-diagnostic-of-ternary-operator-missing-only-colon
May 20, 2023
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
192d7af
Fix diagnostic of ternary operator missing only colon
TTOzzi b769363
Modify tokenKind comparison logic to use "at" function
TTOzzi 24f4274
Formatting
TTOzzi 9184378
Remove check logic for expressions after a colon from ternary operators
TTOzzi f302ac9
Added test case for missing both colon and rhs expression in ternary …
TTOzzi 9bf8ff2
Add logic to check if the next token starts on a new line when there …
TTOzzi 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
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.
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.
Contrary to my first comment, I just had a thought. What do we produce if we have the following?
I think in this case we should be suggesting to add
: <#expression#>
and not just a standalone colon. To achieve that you might need to revert to the old code and just add an additional check for whether the next token is on the same line or a new line.Uh oh!
There was an error while loading. Please reload this page.
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.
In the latest commit of this PR, it returns the diagnostic
"expected ':' after '? ...' in ternary expression."
The Swift compiler in Xcode works the same way.
However, as you mentioned, I think it is appropriate to suggest adding
: <#expression#>
to the code.I will proceed to work on it further and add a commit in this PR!