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

Removing return in front of try await #1818

Open
knutanderss opened this issue Aug 14, 2024 · 1 comment
Open

Removing return in front of try await #1818

knutanderss opened this issue Aug 14, 2024 · 1 comment

Comments

@knutanderss
Copy link

Hi, we had an instance in our codebase where SwiftFormat removed return as redundant in front of try await withCheckedThrowingContinuation { ... }, which caused a type error. The outer function returns Void, and withCheckedThrowingContinuation is generic on its return type, so without return the compiler is not able to infer that the generic parameter should be Void too.

It seems perhaps that return is not redundant in front of try await ...?

Anyway, disabling redundantReturn for that line works for now.

@nicklockwood
Copy link
Owner

@knutanderss I'm having a little bit of trouble visualizing the scenario you are talking about. Is it something like this?

func voidFunc() -> Void {
    return try await withCheckedThrowingContinuation { ... }
}

If not, perhaps you could provide a code example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants