Skip to content

[cxx-interop] Do not crash when calling a subscript with unnamed parameter #73337

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

Merged
merged 1 commit into from
May 6, 2024

Conversation

egorzhdan
Copy link
Contributor

This fixes a crash in SILGen when calling a C++ subscript that has an unnamed parameter from Swift.

The parameters from a C++ operator[] get carried over to the synthesized Swift subscript. If the Swift parameter has no name, there is no way to refer to it in SIL. However, the synthesized subscript accessor needs to pass this parameter to C++.

This change makes sure that we give a name to the Swift parameter if there isn't already a name on the C++ side.

rdar://83163841

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Apr 30, 2024
@egorzhdan egorzhdan requested review from zoecarver and hyp as code owners April 30, 2024 13:44
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan requested a review from beccadax April 30, 2024 21:46
…meter

This fixes a crash in SILGen when calling a C++ subscript that has an unnamed parameter from Swift.

The parameters from a C++ `operator[]` get carried over to the synthesized Swift subscript. If the Swift parameter has no name, there is no way to refer to it in SIL. However, the synthesized subscript accessor needs to pass this parameter to C++.

This change makes sure that we give a name to the Swift parameter if there isn't already a name on the C++ side.

rdar://83163841
@egorzhdan egorzhdan force-pushed the egorzhdan/unnamed-subscript-param branch from 2220e8d to ae27e88 Compare May 1, 2024 11:30
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit c88e65b into main May 6, 2024
@egorzhdan egorzhdan deleted the egorzhdan/unnamed-subscript-param branch May 6, 2024 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants