-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[DiagnosticBridge] Make sure that diagnostic queues up its child notes #79812
Merged
xedin
merged 4 commits into
swiftlang:main
from
xedin:swift-formatter-should-print-child-notes
Mar 7, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
8a0dc2b
[DiagnosticBridge] Make sure that diagnostic queues up its child notes
xedin b7eecc3
[Frontend] Treat empty diagnostic category as "not present"
xedin b26c8aa
[Tests] NFC: Add a test-case for printing child notes associated with…
xedin a7a9a4d
[DiagnosticsBridge] Treat empty category name as `nil`
xedin 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 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 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 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 |
---|---|---|
|
@@ -66,6 +66,9 @@ foo(b: | |
1, | ||
a: 2) | ||
|
||
// Test for child notes attached directly to a "primary" error/warning diagnostic | ||
func test(a: Int) {} | ||
func test(a: Int) {} | ||
|
||
// Test fallback for non-ASCII characters. | ||
// CHECK: SOURCE_DIR{{[/\]+}}test{{[/\]+}}diagnostics{{[/\]+}}pretty-printed-diagnostics.swift:[[#LINE:]]:11 | ||
|
@@ -85,3 +88,9 @@ foo(b: | |
// CHECK: [[#LINE]] | foo(b: 1, a: 2) | ||
// CHECK: | `- error: argument 'a' must precede argument 'b' | ||
// CHECK: [[#LINE+1]] | | ||
|
||
// CHECK: SOURCE_DIR{{[/\]+}}test{{[/\]+}}diagnostics{{[/\]+}}pretty-printed-diagnostics.swift:[[#LINE:]]:6 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'd be nice to check for the error here too, I was initially very confused by this and thought that it was somehow a note off on its own 😅 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ✅ |
||
// CHECK: [[#LINE-1]] | func test(a: Int) {} | ||
// CHECK: | `- note: 'test(a:)' previously declared here | ||
// CHECK: [[#LINE]] | func test(a: Int) {} | ||
// CHECL: [[#LINE+1]] | `- error: invalid redeclaration of 'test(a:)' |
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.
Might be clearer to move this up into
enqueueDiagnostic
?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.
I'd prefer to keep this in here for now since this is technically an implementation detail a "primary" diagnostic and ideally should be dispatched as an argument like what I mentioned in a TODO.
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.
Unless I'm misunderstanding, the infrastructure currently assumes that notes are attached to the first primary diagnostic in the group. Ie.
enqueueDiagnostic
isn't necessarily a primary diagnostic anyway. But 🤷♂️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.
You might be talking about lower level things but there is a dedicated API in DiagnosticEngine which let's the users attach notes directly to the diagnostic they want. I think we should replace all of the disjoint emission of notes with
diagnoseWithNotes
and remove any inference that happens later on...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.
Yeah, all for moving to
diagnoseWithNotes
. Happy to leave it where it is 👍