-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Unable to return a sending value as sending without an error #75473
Comments
I think that you are misunderstanding what is happening here. Part of this is that we do not have isolation history yet (which would explain exactly what is happening with value). What is happening here is that Transaction.with is actor isolated I believe b/c it captures context (which is actor isolated). That then would cause value to be also actor isolated. Btw a tip for you that might be helpful... you can dump the silgen using -emit-silgen to figure out quickly what the isolation is of specific functions... we print out the inferred isolation of functions. As an example using your test case: // closure #1 in MyActor.withContext<A>(_:)
// Isolation: actor_instance. name: 'self'
sil private [ossa] @$s5test27MyActorC11withContextyxxAA0E0CKXEYaKlFxAA11TransactionVzKXEfU_ : $@convention(thin) <T> (@inout Transaction, @guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (@guaranteed Context) -> (@out τ_0_0, @error any Error) for <T>, @sil_isolated @guaranteed MyActor) -> (@out T, @error any Error) { |
Yeah, that isolation history thing sounds amazing. And I totally believe I could be confused! But here's what I do not get. Doesn't a If there was an error in |
@mattmassicotte so I just took another look at this. I actually misread your post. I thought you were referring to the sending on withContext, not the sending on with. My apologies. I think there is an issue here. |
No problem at all! I've also since realized that the signature of with doesn't make sense. I intended it to be this, but I think I just got derailed.
And while that affects the overall correctness of the code example, I think this issue still stands. Plus, that particular version currently crashes as noted in #75982 |
Wow, this is amazing! Thank you so much for looking at this again. |
@mattmassicotte can you verify with the next snapshot that comes out? Then I think we can close this out? Or we can wait until this hits Xcode (eventually) and close it out then... your choice. |
I check it out as soon as a new snapshot is released! |
Just tested this out with the Sept 11 snapshot, but no change. I assume that this change just wasn't picked up yet. |
@gottesmm do you think this is something that might make it into the 6.1 release? |
Verified with 6.1 snapshot. Thank you, this rocks! |
Description
It seems like something about the use of self's state within the closure is defeating
sending
. I would have assumed thatvalue
here would always be possible to send.Reproduction
Expected behavior
I think I understand why
value
is considered self-isolated. But, because it is markedsending
, it really seems like it should be guaranteed possible to send, no?Environment
Apple Swift version 6.0-dev (LLVM ec7116ccf9bd8a8, Swift e6aae02)
Target: arm64-apple-macosx14.0
Additional information
No response
The text was updated successfully, but these errors were encountered: