Skip to content

False positive in isolation checking subscript isolated to an argument #80992

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

Closed
nickolas-pohilets opened this issue Apr 22, 2025 · 1 comment · Fixed by #81022
Closed

False positive in isolation checking subscript isolated to an argument #80992

nickolas-pohilets opened this issue Apr 22, 2025 · 1 comment · Fixed by #81022
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features

Comments

@nickolas-pohilets
Copy link
Contributor

nickolas-pohilets commented Apr 22, 2025

Description

Attached examples demonstrates a valid code which produces unexpected compilation error

Reproduction

struct WritableActorKeyPath<Root: Actor, Value>: Sendable {
    var getter: @Sendable (isolated Root) -> Value
    var setter: @Sendable (isolated Root, Value) -> Void

    subscript(_ root: isolated Root) -> Value {
        get { getter(root) } // error: call to actor-isolated function in a synchronous actor-isolated context
        nonmutating set { setter(root, newValue) } // error: call to actor-isolated function in a synchronous actor-isolated context
    }
}

Expected behavior

Example should compile without errors

Environment

$ xcrun swiftc -version
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Target: arm64-apple-macosx15.0

Additional information

Note that issue does not reproduce for plain functions, only for subscripts:

func testGet<Root: Actor, Value>(_ root: isolated Root, getter: (isolated Root) -> Value) -> Value {
    return getter(root) // ok
}

func testSet<Root: Actor, Value>(_ root: isolated Root, setter: (isolated Root, Value) -> Void, newValue: Value) {
    setter(root, newValue) // ok
}

No response

@nickolas-pohilets nickolas-pohilets added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Apr 22, 2025
@nickolas-pohilets
Copy link
Contributor Author

Looks like isIsolated flag is not copied here -

if (subscriptParam->isCallerIsolated())

@hborla hborla added concurrency Feature: umbrella label for concurrency language features and removed triage needed This issue needs more specific labels labels May 2, 2025
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. concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants