Introduce two new diagnostic groups: RegionIsolationCrossIsolationDataRace and RegionIsolationUnknownPattern, both linked as children of the existing RegionIsolation group. This converts the merge-region-failure errors and the unknown-pattern error from plain ERROR to GROUPED_ERROR, which allows users to selectively downgrade these diagnostics (e.g. the unknown pattern error can be downgraded since it represents a compiler limitation rather than a definite user error). Add user-facing documentation for both groups explaining what triggers the diagnostics and how to resolve them. rdar://175771878
1.2 KiB
Cross-isolation data race (RegionIsolationCrossIsolationDataRace)
Overview
The region-based isolation checker tracks values using regions, which are conservative approximations of object graphs. A region can be either non-isolated or isolated to a single concurrency domain (an actor, a global actor, or the current task), but it can never be isolated to more than one concurrency domain at a time.
This error occurs when an operation would merge two regions that are isolated to different concurrency domains. Merging such regions would allow values from both domains to be referenced through the same object graph, risking concurrent access and data races.
Common examples include assigning an actor-isolated value to a variable accessible from a different isolation domain, passing values from different isolation domains as arguments to the same function call, or casting a value to a type with different isolation.
To resolve this, ensure that values from different isolation domains are not mixed together in ways that could allow concurrent access. Consider making the types involved conform to Sendable, or restructuring the code so that values are only accessed from a single isolation domain.