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

Swift 5.9 + disabling redundantReturn error #1565

Closed
JOyo246 opened this issue Nov 2, 2023 · 4 comments
Closed

Swift 5.9 + disabling redundantReturn error #1565

JOyo246 opened this issue Nov 2, 2023 · 4 comments
Labels
bug fixed in develop bug/feature resolved in the develop branch

Comments

@JOyo246
Copy link

JOyo246 commented Nov 2, 2023

When bumping our swift version to 5.9, and also disabling redundantReturn, we are seeing a bug with if/switch expressions.

Swift 5.8 Code

enum MyEnum {
    case a
    case b
}
let myEnum = MyEnum.a
let test: Int = {
    switch myEnum {
    case .a:
        return 0
    case .b:
        return 1
    }
}()

After bumping to 5.9, disabling redundantReturn and running swiftformat, we get...

enum MyEnum {
    case a
    case b
}
let myEnum = MyEnum.a
    
let test: Int = switch myEnum {
    case .a:
        return 0
    case .b:
        return 1
}

which is an error, Cannot 'return' in 'switch' when used as expression

@calda
Copy link
Collaborator

calda commented Nov 4, 2023

Here's a fix: #1567

@nicklockwood
Copy link
Owner

@calda oh ha ha, I was just finishing up my own fix 🤦‍♂️

I think I prefer my approach, but I'll steal your test suite - thanks!

@calda
Copy link
Collaborator

calda commented Nov 4, 2023

Haha, thats funny, np! Will be interested to see your approach

@nicklockwood nicklockwood added the fixed in develop bug/feature resolved in the develop branch label Nov 4, 2023
@nicklockwood
Copy link
Owner

@JOyo246 fixed in 0.52.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fixed in develop bug/feature resolved in the develop branch
Projects
None yet
Development

No branches or pull requests

3 participants