apple / swift-docc

Documentation compiler that produces rich API reference documentation and interactive tutorials for your Swift framework or package.
https://swift.org/documentation/docc
Apache License 2.0
1.14k stars 118 forks source link

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

Closed d-ronnqvist closed 3 weeks ago

d-ronnqvist commented 3 weeks ago

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.

d-ronnqvist commented 3 weeks ago

@swift-ci please test

Kyle-Ye commented 3 weeks ago

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

d-ronnqvist commented 3 weeks ago

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

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