Skip to content
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

sending closure parameter function used in top-level can't catch cross border. #78329

Open
carlhung opened this issue Dec 20, 2024 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@carlhung
Copy link

Description

sending closure parameter function used in top-level can't catch cross border.

Reproduction

public final class NonSendable {
  var value = 0
}

func f4(_ closure: sending @escaping () async -> Void) {
  Task.detached {
    await closure()
  }
}

do {
    let nonSendable = NonSendable()
    f4 {
      nonSendable.value = 0
        print(nonSendable.value)
      
    }
    // it should not be able to assign a new value.
    nonSendable.value = 0
    print(nonSendable.value)
}

Expected behavior

showing an error.

Environment

Swift version 6.0.1 (swift-6.0.1-RELEASE) Target: aarch64-unknown-linux-gnu

Additional information

No response

@carlhung carlhung added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Dec 20, 2024
@jamieQ
Copy link
Contributor

jamieQ commented Dec 23, 2024

associated forum discussion: https://forums.swift.org/t/sending-closure/76780

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

2 participants