Skip to content

[region-isolation] Add support for transferring parameters. #70836

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 5 commits into from
Jan 19, 2024

Conversation

gottesmm
Copy link
Contributor

A transferring parameter is a consuming like param modifier that can be used to transfer values to an async function such that you can transfer the value further.

Since it is consuming, one can assign into it. When one assigns into it, one has transferred the new value into the transferred parameter.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

swiftlang/swift-syntax#2410

@swift-ci smoke test

@gottesmm gottesmm force-pushed the transferring-parameter branch from 5f1b488 to f623b4e Compare January 17, 2024 20:18
@gottesmm
Copy link
Contributor Author

swiftlang/swift-syntax#2410

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

(just rebasing/retesting since I am back from vacation)

@gottesmm
Copy link
Contributor Author

Looks like the windows/macOS failures are related to swiftpm

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

NOTE: This does not handle yet assignment into transferring parameters. In the
next commit, I am going to teach the checker that assigning into such a
parameter is a transfer.
…ferring parameter is a transfer of the value.

The specific semantics is if we assign into a transferring parameter's field,
then we "merge" src's value into the transferring parameter, so we
conservatively leave the region of the transferring parameter alone. If we
assign over the entire transferring parameter, we perform an assign fresh since
any value that used to be in the transferring parameter cannot reference
anything in its new value since they are all gone.
…d optionals.

llvm::Optional<T> used to make it so that in asserts builds if one dereferenced the optional and nothing was there, one would get an assert. std::optional<T> does not have that property.
…r being strongly transferred is an error.

Before the previous patch, we were just getting lucky on macOS due to UB. Now
that the UB is fixed, we correctly crash without this commit since we were not
pattern matching the simple case of a local value that was transferred and used
later.
@gottesmm gottesmm force-pushed the transferring-parameter branch 2 times, most recently from c50e171 to eb57309 Compare January 18, 2024 21:22
@gottesmm
Copy link
Contributor Author

swiftlang/swift-syntax#2410

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

I got feedback from some people about some small changes about loosening the rules around assigning into a transferring parameter. I am going to do that in a follow on commit. This at least gets in the basics and ensures that I do not hit more merge conflicts around Serialization.

@gottesmm gottesmm merged commit 50aaad3 into swiftlang:main Jan 19, 2024
@gottesmm gottesmm deleted the transferring-parameter branch January 19, 2024 19:11
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