don't crash on an extension with an empty declaration #635
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.
Bug/issue #, if applicable: rdar://110683602
Summary
In current development builds of the Swift compiler, some extension block symbols are emitted with an empty
declarationFragments
array. This causes the extension block symbol converter to crash with an out-of-bounds access when it tries to strip away theextension SomeType
part of the declaration to find its where clause. This PR fixes this logic by guarding against the length of the array as well as its existence.Dependencies
None
Testing
I haven't isolated how to properly reproduce this (other than "export-import Foundation in a project"), so the test is restricted to the sample data i added in this branch.
Steps:
swift run docc convert 'Tests/SwiftDocCTests/Test Bundles/ModuleWithEmptyDeclarationFragments.docc'
Checklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/test
script and it succeeded