Skip to content

Use presumed file/line number when printing grouped diagnostics #2501

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
Feb 19, 2024

Conversation

DougGregor
Copy link
Member

For the primary diagnostic, print the presumed file/line number in the same manner as the Swift compiler does. In the actual code listing, keep the line numbers and code from the actual source file that was parsed, because there's no sensible way to map the source from the #sourceLocation-named file (which might not exist).

For the primary diagnostic, print the presumed file/line number in the
same manner as the Swift compiler does. In the actual code listing,
keep the line numbers and code from the actual source file that was
parsed, because there's no sensible way to map the source from the
`#sourceLocation`-named file (which might not exist).
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor enabled auto-merge February 19, 2024 04:07
@DougGregor
Copy link
Member Author

@swift-ci please test Linux

@DougGregor
Copy link
Member Author

@swift-ci please test macOS

@DougGregor
Copy link
Member Author

@swift-ci please clean test macOS

@DougGregor
Copy link
Member Author

@swift-ci please clean test Linux

@DougGregor
Copy link
Member Author

@DougGregor DougGregor merged commit bff0b28 into swiftlang:main Feb 19, 2024
@DougGregor DougGregor deleted the presumed-loc-in-grouped-diags branch February 19, 2024 17:49
@@ -60,6 +60,31 @@ extension GroupedDiagnostics {
}

final class GroupedDiagnosticsFormatterTests: XCTestCase {
func testSourceLocations() {
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to put the actual file's name somewhere as well, but I have no great suggestions as to where to put it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you elaborate a bit? I'm not quite sure I'm following what you mean. :/

Copy link
Contributor

Choose a reason for hiding this comment

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

With #sourceLocation we have two "files" - the real file on disk (usually generated in this case) and the "presumed" file (the one noted in #sourceLocation). After this change, the file noted in the diagnostic is the presumed file, which matches the Swift compiler. That makes sense since #sourceLocation was added for a reason, but I have found that knowing the underlying file is useful too.

That would have been more clear if I put this comment on the actual #sourceLocation line :)

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.

3 participants