nicklockwood / SwiftFormat

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

Invalid `self.` insertion with capture list #1424

Closed keith closed 1 year ago

keith commented 1 year ago

With this code:

class B {
    func bar() {}
}
class A {
    var thing: B? { fatalError() }

    func foo() {
        let thing2 = B()
        let _: (Bool) -> Void = { [weak thing = thing2] _ in
            thing?.bar()
        }
    }
}

In the closure self. is inserted before thing even though it shouldn't be since the thing binding in the capture list was the intended target

nicklockwood commented 1 year ago

@keith fixed in 0.51.7