Skip to content

Project-wide "Pattern that the region based isolation checker does not understand how to check" #76005

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
Supereg opened this issue Aug 21, 2024 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features SILOptimizer Area → compiler: SIL optimization passes

Comments

@Supereg
Copy link

Supereg commented Aug 21, 2024

Description

There have been previous reports of this compiler warning popping up, that was fixed in Xcode Beta 5 (#75439, #75128, #75238). I just now installed Xcode Beta 6 and have hoped this warning to disappear but it remains. However, for me the warning is not associated with a specific line or file but is printed as:

<unknown>:0: warning: pattern that the region based isolation checker does not understand how to check. Please file a bug; this is an error in the Swift 6 language mode

This error occurs when compiling the StanfordSpezi/SpeziBluetooth SPM package (commit hash as of time of writing 8ee8ba902cff833aa6a6062fc8433e5d0e0338f3). The warning is printed 8 times, each when compiling the files resource_bunle_accessor.swift (file generated by Xcode), Bluetooth.swift, DeviceDiscoveryDescriptor.swift, Discover.swift, DiscoveryDescriptorBuilder, BluetoothManager.swift, BluetoothPeripheral.swift and CharacteristicDescription.swift. Except for the first file, all of the files are part of the project.

Most of these files are non-trivial. The project is otherwise compatible with Swift 6 strict concurrency checking.

This issue is intended to ask for assistance in tracking down the exact issue for this warning. Are there any magic switches to pull that would provide more information where the warning is generated from? Or might this be related to a known issue that was reported somewhere else (hopefully in a more reproducible manner) that is about to be fixed?

Reproduction

As explained above, I currently cannot isolate it to a single line of code due to the cryptic compiler warning. The only steps for reproduction I can point to is the project where the error occurs.

Expected behavior

Report a more useful diagnostic that includes the file and line number where this error/warning occurs.

Environment

Xcode Beta 6

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
Target: arm64-apple-macosx14.0

Additional information

No response

@Supereg Supereg added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Aug 21, 2024
@Supereg
Copy link
Author

Supereg commented Aug 21, 2024

cc @gottesmm you seem to get mentioned with these warnings in the other issue reports.

@Supereg
Copy link
Author

Supereg commented Aug 21, 2024

Attaching the full build log

Build SpeziBluetooth-Package_2024-08-21T09-26-58.txt

@Supereg
Copy link
Author

Supereg commented Sep 9, 2024

The issue persists with Xcode 16 RC release today.

@xedin xedin added concurrency Feature: umbrella label for concurrency language features compiler The Swift compiler itself SILOptimizer Area → compiler: SIL optimization passes and removed triage needed This issue needs more specific labels labels Sep 9, 2024
@xedin
Copy link
Contributor

xedin commented Sep 9, 2024

cc @gottesmm

@Supereg
Copy link
Author

Supereg commented Nov 10, 2024

Any updates on this? This issue persists in Version 16.1 (16B40) and remains a significant blocker for adopting Swift 6.

I’ve eventually managed to isolate the problem to a minimal setup, which consistently reproduces the error.

It will yield the following error for one or more files (even if the code is only contained in a single file):

<unknown>:0: error: pattern that the region based isolation checker does not understand how to check. Please file a bug

The example defines a type TestClass that is isolated to a custom global actor TestActor and contains a property wrapper PropertyWrapper that is isolated to the @mainactor. Note, this example doesn't trigger when using simple types like Int but only triggers with a type like Values.

@propertyWrapper
class PropertyWrapper<Value> {
    var wrappedValue: Value

    init(wrappedValue: Value) {
        self.wrappedValue = wrappedValue
    }
}

@MainActor
struct Values {
    nonisolated init() {}
}

@globalActor
actor TestActor {
    static let shared = TestActor()
}

@TestActor
final class TestClass: Sendable {
    @MainActor @PropertyWrapper var property: Values

    @MainActor
    init(_ value: Int) {
        self.property = Values()
    }
}

You cannot initialize the underlying storage property of the property wrapper as this yields the error shown below. Annotating the property wrapper with @MainActor, I would have suspected that the underlying storage property is also initialized to the MainActor(?). Independent of the correctness of the code, they main point this issue raises is that the error message is not meaningful and really doesn't help to explain nor locate the issue.

    @MainActor
    init(_ value: Int) {
        self._property = PropertyWrapper(wrappedValue: Values()) // error: Global actor 'TestActor'-isolated property '_property' can not be mutated from the main actor
    }
``

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. compiler The Swift compiler itself concurrency Feature: umbrella label for concurrency language features SILOptimizer Area → compiler: SIL optimization passes
Projects
None yet
Development

No branches or pull requests

2 participants