Skip to content

[SILGen] Handle struct projectedValue in struct property wrapper that has mutating setter #81232

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stzn
Copy link
Contributor

@stzn stzn commented May 1, 2025

Resolves #81021

When the projectedValue is a struct within a struct property wrapper that has a mutating setter, and we use the property wrapper as a function parameter, the projectedValue becomes an Rvalue and does not have an address.

This issue does not occur if the property wrapper is a class, or if the projectedValue itself is a class.

Previously, we did not handle this case, which led to an assertion failure in the following code:

if (!address.isLValue()) { 
       // If it is a case described the above, `AccessKind` is `SGFAccessKind::ReadWrite`
        assert((AccessKind == SGFAccessKind::BorrowedObjectRead
                || AccessKind == SGFAccessKind::BorrowedAddressRead)
               && "non-borrow component requires an address base");

Since it is not an address, we could not treat it the same as the borrow cases.

Therefore, we needed to handle this scenario differently.

@stzn stzn marked this pull request as ready for review May 1, 2025 10:36
@stzn stzn requested a review from jckarter as a code owner May 1, 2025 10:36
@drexin
Copy link
Contributor

drexin commented May 9, 2025

@swift-ci smoke test

@stzn
Copy link
Contributor Author

stzn commented May 14, 2025

@drexin
Thank you for running CI.
I don’t know if it’s right to ask you, but do you know who I should request to review this PR?

@drexin
Copy link
Contributor

drexin commented May 15, 2025

cc: @jckarter

@stzn
Copy link
Contributor Author

stzn commented Jun 7, 2025

@jckarter

Hi, what should I do next? Thank you.

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.

Property wrapper with writable projectedValue causes IRGen crash when used as a function parameter
2 participants