Skip to content

Handle various out-of-bounds diagnostic ranges in default diagnostics formatter #947

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

Conversation

d-ronnqvist
Copy link
Contributor

Bug/issue #, if applicable: #729

Summary

This improved the input validation of the default diagnostic formatter so that incorrectly created diagnostics with out-of-bounds range information won't cause a crash.

Dependencies

None.

Testing

Since this needs an incorrectly created diagnostic, it requires a bug that results in out-of-bounds diagnostics to test.

This comment includes a package that reproduces on such bug. Building it should no longer crash (although it will output a duplicate diagnostic, because that issue is not fixed in this PR).

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary Not applicable

@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@Kyle-Ye
Copy link
Contributor

Kyle-Ye commented Jun 11, 2024

LGTM. Any plan to cherry-pick this back to release/6.0?

@d-ronnqvist
Copy link
Contributor Author

LGTM. Any plan to cherry-pick this back to release/6.0?

Yes. I think it's safe and small enough for that.

@d-ronnqvist d-ronnqvist merged commit 9e212e5 into swiftlang:main Jun 11, 2024
d-ronnqvist added a commit to d-ronnqvist/swift-docc that referenced this pull request Jun 11, 2024
… formatter (swiftlang#947)

* Clamp lines to highlight in a diagnostic to the source lines

* Add test about highlight for in-bounds range of a line

* Clamp diagnostic line highlight to the bounds of each source line

rdar://129586253
@d-ronnqvist d-ronnqvist deleted the duplicate-image-diagnostic-crash branch June 11, 2024 14:21
@Kyle-Ye Kyle-Ye linked an issue Jun 12, 2024 that may be closed by this pull request
2 tasks
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.

Duplicated diagnostic causing crash on DefaultDiagnosticConsoleFormatter
2 participants