Skip to content
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

Swift 6 boundary issue fix #256

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Swift 6 boundary issue fix #256

merged 1 commit into from
Aug 6, 2024

Conversation

hallee
Copy link
Contributor

@hallee hallee commented Aug 4, 2024

There's currently an error in release builds related to isolation of operation:

482 |   @_transparent
483 |   private func isSetting<R>(
    |                          `- note: consider making generic parameter 'R' conform to the 'Sendable' protocol
484 |     _ value: Bool,
485 |     isolation: isolated (any Actor)? = #isolation,
    :
489 |       try await DependencyValues.$isSetting.withValue(value, operation: operation)
490 |     #else
491 |       try await operation()
    |                 `- error: non-sendable type 'R' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
492 |     #endif
493 |   }

I believe the correct fix for this is marking operation with the sending keyword. Here's the Swift proposal for that keyword, maybe someone who better understands concurrency should confirm that my understanding is correct: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0430-transferring-parameters-and-results.md

Fixes #255

@cuteiosdev
Copy link

Have tested this change and it addresses issue #255. Not sure if there are other concurrency concerns related to the fix though.

@stephencelis
Copy link
Member

stephencelis commented Aug 6, 2024

I think the only question here is around Swift 6 snapshots being a rapidly moving target at the moment. While we're definitely open to merging this if it fixes the problem, I think we'd also like the Swift team to acknowledge if this is an expected requirement or if its boundary-checking system should infer sending here. Do either of you want to ask on the forums or open a Swift issue? Or would you like us to do so?

@cuteiosdev
Copy link

cuteiosdev commented Aug 6, 2024

I was hopeful that we would get a new Xcode beta build today and see if that was fixed, but that didn't happen. For iOS / macOS apps it only manifests on archive builds so I'm inclined to be cautious. I'll ask over in the swift forums about this and see if there's any advice / direction to go with.

@stephencelis
Copy link
Member

@cuteiosdev Thanks! Please keep us posted! If you reply with the forum thread here I'll be sure to follow it

@cuteiosdev
Copy link

Discussion has been raised over on the Swift Forum at https://forums.swift.org/t/sendable-error-when-creating-archive-build-and-swift-6/73726

@cuteiosdev
Copy link

@stephencelis it looks like the fix here appears to be the right one from discussion in the Swift forums and also on mastodon.

@Andrewangeta
Copy link

This would also address #253

@stephencelis stephencelis merged commit d7472be into pointfreeco:main Aug 6, 2024
3 checks passed
@mbrandonw mbrandonw mentioned this pull request Aug 21, 2024
3 tasks
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.

Archive build failure when using Swift 6
4 participants