Skip to content

Disable destructuring initializations in struct let stored properties. #68930

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

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Oct 3, 2023

This looks like it was never properly implemented, since when we generate the memberwise initializer for the struct in SILGen, it incorrectly tries to apply the entire initializer expression to each variable binding in the pattern, rather than destructuring the result and pattern-matching it to the variables. Since it never worked it doesn't look like anyone is using this, so let's put up an error saying it's unsupported until we can implement it properly. Add StructLetDestructuring as an experimental feature flag so that tests around the feature for things like module interface printing can still work.

Fixes #68915 | rdar://116343732.

@jckarter
Copy link
Contributor Author

jckarter commented Oct 3, 2023

@swift-ci Please test source compatibility

@jckarter jckarter force-pushed the disable-let-stored-property-destructuring branch from 5d278a1 to 709beb1 Compare October 3, 2023 15:24
@jckarter
Copy link
Contributor Author

jckarter commented Oct 3, 2023

@swift-ci Please test source compatibility

@jckarter jckarter force-pushed the disable-let-stored-property-destructuring branch from 709beb1 to 1425473 Compare October 3, 2023 15:26
@jckarter
Copy link
Contributor Author

jckarter commented Oct 3, 2023

@swift-ci Please test source compatibility

@jckarter jckarter force-pushed the disable-let-stored-property-destructuring branch from 1425473 to 7c755ea Compare October 3, 2023 19:44
This looks like it was never properly implemented, since when we generate the
memberwise initializer for the struct in SILGen, it incorrectly tries to apply
the entire initializer expression to each variable binding in the pattern,
rather than destructuring the result and pattern-matching it to the variables.
Since it never worked it doesn't look like anyone is using this, so let's
put up an error saying it's unsupported until we can implement it properly.
Add `StructLetDestructuring` as an experimental feature flag so that tests around
the feature for things like module interface printing can still work.
@jckarter jckarter force-pushed the disable-let-stored-property-destructuring branch from 7c755ea to b4f5369 Compare October 3, 2023 20:25
@jckarter
Copy link
Contributor Author

jckarter commented Oct 3, 2023

@swift-ci Please test

@jckarter jckarter changed the title [wip] disable let stored property destructuring Disable destructuring initializations in struct let stored properties. Oct 3, 2023
@jckarter jckarter marked this pull request as ready for review October 3, 2023 21:11
@jckarter jckarter merged commit 151950d into swiftlang:main Oct 4, 2023
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.

Incorrect tuple destructure
2 participants