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 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

1 similar comment
@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

@kavon kavon force-pushed the rdar159079818-subscript-read-nc branch from d6ee140 to 5dc9963 Compare August 28, 2025 19:17
@kavon
Copy link
Member Author

kavon commented Aug 28, 2025

@swift-ci test source compatibility

@kavon
Copy link
Member Author

kavon commented Aug 29, 2025

@swift-ci please test

kavon added 3 commits August 29, 2025 13:30
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.

I've limited the existentials fix to noncopyables
for now.

part of rdar://159079818
@kavon kavon force-pushed the rdar159079818-subscript-read-nc branch from 5dc9963 to 16c5c36 Compare August 29, 2025 22:12
@kavon
Copy link
Member Author

kavon commented Aug 29, 2025

Full test passed for all but the one test I needed to update, which I've done now.

@swift-ci smoke test

@kavon kavon marked this pull request as ready for review August 29, 2025 22:13
@kavon kavon requested a review from jckarter as a code owner August 29, 2025 22:13
@kavon
Copy link
Member Author

kavon commented Aug 29, 2025

Error response from daemon: No such container: swift-pr

@swift-ci smoke test

@kavon kavon enabled auto-merge August 29, 2025 22:22
@kavon kavon merged commit 511971f into swiftlang:main Aug 30, 2025
3 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