Skip to content

Conversation

kavon
Copy link
Member

@kavon kavon commented Aug 27, 2025

If a subscript uses a read accessor to yield a noncopyable value, we'd emit an end_apply that's too tightly scoped to allow for a subsequent borrowing access on the yielded value.

resolves rdar://159079818

kavon added 2 commits August 27, 2025 17:00
If a subscript uses a read accessor to yield a noncopyable value,
we'd emit an `end_apply` that's too tightly scoped to allow for
a subsequent borrowing access on the yielded value.

resolves rdar://159079818
We were not able to use an existential as the base
of an access that strictly borrows the existential,
because SILGen's RValue emission would establish
a fresh evaluation scope just for the existential's
opening, and then copy the opened value out.

This is problematic for noncopyable existentials.

So this patch moves & adds FormalEvaluationScope's
around so they're broad enough to enable a
borrow of an existential. The idea behind this
refactoring is to establish top-level
FormalEvaluationScopes when initially creating
RValue's for Expr's in SILGen. Any more-tightly
scoped operations will already establish their own
nested scope, so this is mostly adding safe-guards.
@kavon kavon force-pushed the rdar159079818-subscript-read-nc branch from 016621c to c6a9706 Compare August 28, 2025 00:26
@kavon
Copy link
Member Author

kavon commented Aug 28, 2025

@swift-ci smoke test

@kavon
Copy link
Member Author

kavon commented Aug 28, 2025

@swift-ci smoke test

@kavon
Copy link
Member Author

kavon commented Aug 28, 2025

@swift-ci test source compatibility

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.

1 participant