Skip to content

False positive warning about closure isolation but only when argument label is omitted #75522

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
groue opened this issue Jul 27, 2024 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features

Comments

@groue
Copy link

groue commented Jul 27, 2024

Description

The compiler changes its diagnostic depending on whether a closure argument is declared with or without argument label.

Reproduction

struct SUT {
    func run1(completion: sending @escaping () -> Void) { }
    func run2(_ completion: sending @escaping () -> Void) { }
}

@MainActor
func test_run() {
    let sut = SUT()

    // No warning
    sut.run1 { }

    // Main actor-isolated value of type '() -> ()' passed as a strongly
    // transferred parameter; later accesses could race
    sut.run2 { }
}

This is very confusing.

Expected behavior

No warning in both cases.

Environment

% swiftc -version
swift-driver version: 1.112.3 Apple Swift version 6.0 (swiftlang-6.0.0.6.8 clang-1600.0.23.1)
Target: arm64-apple-macosx14.0

Additional information

No response

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

groue commented Jul 27, 2024

Related: #75521

groue added a commit to groue/GRDB.swift that referenced this issue Jul 27, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Jul 27, 2024
@hborla hborla added concurrency Feature: umbrella label for concurrency language features and removed triage needed This issue needs more specific labels labels Jul 27, 2024
groue added a commit to groue/GRDB.swift that referenced this issue Jul 28, 2024
@gottesmm
Copy link
Contributor

gottesmm commented Oct 9, 2024

@groue so this doesn't reproduce on main anymore. It was fixed in

tags/swift-DEVELOPMENT-SNAPSHOT-2024-08-28-a..tags/swift-DEVELOPMENT-SNAPSHOT-2024-08-29-a.

So one of these commits:

406b8bd Merge pull request #76133 from slavapestov/sync-local-func-isolation
543fd21 Merge pull request #76125 from ian-twilightcoder/unknown-platform-attr
8503f72 Merge pull request #76111 from tshortli/lazy-typecheck-lazy-var-in-inlinable-func
dfa60a1 Merge pull request #76101 from kateinoigakukun/yt/update-swift-collection-113
3436c49 Merge pull request #76123 from hamishknight/a-form-of-expression
6465bdc Merge pull request #76042 from xedin/rdar-133415157
00eee36 Merge pull request #76115 from xedin/rdar-131524246

@groue
Copy link
Author

groue commented Oct 9, 2024

Thank you @gottesmm :-) Glad the bug is fixed in the latest snapshot, because it is still there in Xcode 16.1 beta 3. #75521 is a similar issue.

@gottesmm
Copy link
Contributor

This is fixed in the 6.1 release.

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

No branches or pull requests

3 participants