Skip to content

Conversation

@sofiaromorales
Copy link
Contributor

@sofiaromorales sofiaromorales commented Oct 14, 2025

Bug/issue #, if applicable: rdar://162596256

Summary

If a bystander array is empty after decoding it, don't initialise the value.

Usually, bystander arrays contain a non-empty array if it's present, and if the SGF has been generated by the Swift/Clang compilers, but if it's present as an empty array for any reason, it can break DocC.

This change checks if the array is empty and if it is, it assigns nil to the bystander variable.

Testing

  1. Run unit tests

  1. Run swift docs preview with a SGF that has an empty bystander array, before this change DocC will crash.

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

If a bystandar array is empty after decoding it don't initialize the value.

Usally this wouldn't happen, but if it does, it can break DocC.

rdar://162596256
@sofiaromorales sofiaromorales force-pushed the sofiaromorales/r162019087-empty-bystanders branch from 77b9a1d to a54c164 Compare October 14, 2025 12:35
@sofiaromorales
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@QuietMisdreavus QuietMisdreavus left a comment

Choose a reason for hiding this comment

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

I'm not jazzed about having a valid JSON pattern not round-trip identically, but empty bystanders lists shouldn't be encoded in the first place. I'm fine with merging this.

@QuietMisdreavus
Copy link
Contributor

@swift-ci Please test

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.

2 participants