Skip to content

[6.0][Runtime] Fix key argument indexing when checking invertible protocols. #74357

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

Conversation

mikeash
Copy link
Contributor

@mikeash mikeash commented Jun 12, 2024

Cherry-pick #74267 to release/6.0.

Track the key argument index separately from the generic parameter index when performing the invertible protocol checking in _checkGenericRequirements. This keeps the indexing correct when a non-key argument is followed by a key argument.

rdar://128774651

…tocols.

Track the key argument index separately from the generic parameter index when performing the invertible protocol checking in _checkGenericRequirements. This keeps the indexing correct when a non-key argument is followed by a key argument.

rdar://128774651
(cherry picked from commit b86fe88)
@mikeash mikeash requested a review from a team as a code owner June 12, 2024 19:41
@mikeash
Copy link
Contributor Author

mikeash commented Jun 12, 2024

Explanation: Indexing mixup can cause runtime invertible protocol checking to read off the end of a type's generic arguments and crash.
Original PR: #74267
Reviewed by: @al45tair
Risk: Low. This restores correct behavior when key arguments come after non-key arguments, and other behavior is left unchanged.
Resolves: rdar://128774651
Tests: Added a new test to the suite that verifies this particular case, existing tests cover other cases well.

@mikeash
Copy link
Contributor Author

mikeash commented Jun 12, 2024

@swift-ci please test

@mikeash mikeash enabled auto-merge June 12, 2024 19:43
@mikeash mikeash merged commit 372de46 into swiftlang:release/6.0 Jun 13, 2024
5 checks passed
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