nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.87k stars 637 forks source link

Unexpected static keyword #1592

Closed chaewan-park closed 10 months ago

chaewan-park commented 10 months ago

With this code:

public final class MyClass {
    private static func privateStaticFunction1() -> Bool {
        switch Result(catching: { try someThrowingFunction() }) {
        case .success:
            return true
        case .failure:
            return false
        }
    }

    private static func privateStaticFunction2() -> Bool { // <-- Unexpected static keyword
        return false
    }
}

Running swiftformat MyClass.swift fails with:

error: Unexpected static keyword on line 11 in MyClass.swift

And my .swiftformat file has this option:

# format options
--self insert

using 0.52.10

nicklockwood commented 10 months ago

@chaewan-park I'm not able to reproduce this in SwiftFormat 0.52.10 with the following unit test. Perhaps there's some other surrounding context in the file needed to recreate it? Or is it possible you somehow have multiple SwiftFormat versions installed, and are running the wrong one?

EDIT: never mind, I was missing that you were using --self insert - I can reproduce it now.

nicklockwood commented 10 months ago

@chaewan-park fixed in 0.52.11