Skip to content

The compiler fails to resolve concurrency isolation check #77679

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

Open
tapsns opened this issue Nov 18, 2024 · 0 comments
Open

The compiler fails to resolve concurrency isolation check #77679

tapsns opened this issue Nov 18, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@tapsns
Copy link

tapsns commented Nov 18, 2024

Description

For a actor with an async method that returns a sending result, the compiler complains:

Pattern that the region based isolation checker does not understand how to check. Please file a bug

Reproduction

import Cocoa

final class Foo {
  func evaluate(_ image: sending NSImage) async {
    // Do something with the image
  }
}

actor Bar {
  private let provider = ImageProvider()

  public func run() async {
    let image = await provider.makeImage()
    let foo = Foo()
    
    // The compiler complains about the following call.
    await foo.evaluate(image)
  }
}

actor ImageProvider {
  func makeImage() async -> sending NSImage {
    return NSImage()
  }
}

Expected behavior

This code should compile without error. This is simple code that demonstrates the bug. In my real code, I am using an actor to isolate access to a resource.

Note that makeImage() simply creates the image and returns it to caller, so there is no use of it outside of the caller's isolation region.

This is clearly a compiler error given that the compiler is literally saying, "Please file a bug."

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.4 clang-1600.0.30)
Target: arm64-apple-macosx15.0

Additional information

Marking makeImage() as nonisolated avoids the compiler error, but I don't think it would be a general workaround due to the implications of that marker.

@tapsns tapsns added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant