Skip to content

Add to match this opening <thing> notes to the diagnostics #862

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
merged 1 commit into from
Sep 30, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 29, 2022

For diagnostics like expected '}' to end actor issue a corresponding to match this opening '{'

This resolves 38 TODOs, down to 1025.

@ahoppen
Copy link
Member Author

ahoppen commented Sep 30, 2022

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 30, 2022

@swift-ci Please test

@ahoppen ahoppen merged commit b3f093a into swiftlang:main Sep 30, 2022
@ahoppen ahoppen deleted the ahoppen/notes branch October 1, 2022 10:19
if let notes = spec.notes {
if diag.notes.count != notes.count {
XCTFail("""
Expected \(notes.count) notes but received \(diag.notes.count):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could print the expected notes as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I explicitly didn’t print the expected notes because the test failure will point to where the DiagnosticSpec is declared and the expected notes will be shown there anyway. So I think there is very little value in printing the expected notes. This matches what we are doing for diagnostics as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a comment there too :P. I generally like having everything in the error, makes it easier to attach them to issues and figure out the problem at a glance (rather than going to the test, comparing the output to what's in the test, etc). I don't feel particularly strongly about this though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree but fair enough. If you want to add it, I won’t oppose you. 😜

@@ -246,9 +328,10 @@ func AssertParse<Node: RawSyntaxNodeProtocol>(
Expected \(expectedDiagnostics.count) diagnostics but received \(diags.count):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as for notes, would be nice to print all expected as well.

public let position: AbsolutePosition

/// A description of what this note is pointing at.
public let noteMessage: NoteMessage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure having an ID for note/diagnostic is really worth it. But we can keep it for now 🤷

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think it’s very little overhead at this point and once a use case comes up we will be glad that we have so we don’t need to do string matching for the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants