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

Autoclosures and global actors don't work together #67688

Open
KeithBauerANZ opened this issue Aug 2, 2023 · 0 comments
Open

Autoclosures and global actors don't work together #67688

KeithBauerANZ opened this issue Aug 2, 2023 · 0 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features

Comments

@KeithBauerANZ
Copy link

Description

func acceptAutoclosure(_ closure: @autoclosure @MainActor () -> ()) {}

@MainActor
func f() {}

acceptAutoclosure(f())
> swiftc AutoclosureIsolation.swift
AutoclosureIsolation.swift:6:19: error: call to main actor-isolated global function 'f()' in a synchronous nonisolated context
acceptAutoclosure(f())
                  ^
AutoclosureIsolation.swift:4:6: note: calls to global function 'f()' from outside of its actor context are implicitly asynchronous
func f() {}
     ^

I can see that you might want to reject this code (in which case there should be a different error on line 1, about global actors and autoclosures being incompatible), or accept it (in which case there shouldn't be an error at all), but either way, there's a bug here.

Environment
swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

@KeithBauerANZ KeithBauerANZ added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Aug 2, 2023
@hborla hborla self-assigned this Oct 9, 2023
@hborla hborla added concurrency Feature: umbrella label for concurrency language features and removed triage needed This issue needs more specific labels labels Apr 27, 2024
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

2 participants