Skip to content
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

don't crash on an extension with an empty declaration #635

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

QuietMisdreavus
Copy link
Contributor

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 the extension 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:

  1. swift run docc convert 'Tests/SwiftDocCTests/Test Bundles/ModuleWithEmptyDeclarationFragments.docc'
  2. Ensure that docc does not crash when processing the included extension symbol graph.

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
  • [ n/a ] Updated documentation if necessary

@QuietMisdreavus
Copy link
Contributor Author

@swift-ci Please test

Copy link
Contributor

@d-ronnqvist d-ronnqvist left a comment

Choose a reason for hiding this comment

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

LGTM

@d-ronnqvist
Copy link
Contributor

Did I understand correctly that we don't create a page for the empty extension?

@QuietMisdreavus
Copy link
Contributor Author

Correct. The empty extension has no child symbols to curate, so it is not added to the final documentation.

Copy link
Contributor

@theMomax theMomax left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@QuietMisdreavus QuietMisdreavus merged commit 77623b8 into swiftlang:main Jun 21, 2023
@QuietMisdreavus QuietMisdreavus deleted the empty-declaration branch June 21, 2023 16:09
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