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

[SR-15351] curious case of defer MainActor call in a Task #57673

Closed
mattneub opened this issue Oct 18, 2021 · 0 comments · Fixed by #60688
Closed

[SR-15351] curious case of defer MainActor call in a Task #57673

mattneub opened this issue Oct 18, 2021 · 0 comments · Fixed by #60688
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself concurrency Feature: umbrella label for concurrency language features

Comments

@mattneub
Copy link

Previous ID SR-15351
Radar rdar://80799233
Original Reporter @mattneub
Type Bug
Environment

Xcode 13

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee @etcwilde
Priority Medium

md5: 10c8f8913a8f1abbe13d1d31c412ddd3

Issue Description:

Consider:

    @MainActor func foo() {}
    override func viewDidLoad() {
        super.viewDidLoad()
        Task {
            do {
                self.foo() // ok
                defer {
                    self.foo() // compile error
                }
                print("dummy")
            }
        }
    }

The second call to `self.foo()` is a compile error, but the first is not. That seems incoherent, as they are both called from within exactly the same context. The `defer` shouldn't make a difference.

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. compiler The Swift compiler in itself concurrency Feature: umbrella label for concurrency language features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants