I'm working on a new rule and have come across an issue with Formatter's isStartOfClosure function.
A simple test case:
func testFuncNotTreatedAsClosure() {
let formatter = Formatter(tokenize("func test<T: Equatable>(e: T) {}"))
XCTAssertFalse(formatter.isStartOfClosure(at: formatter.tokens.count - 2)) //fails
let formatter2 = Formatter(tokenize("func test(e: T) {}"))
XCTAssertFalse(formatter2.isStartOfClosure(at: formatter2.tokens.count - 2)) //passes
}
It seems to be falling into the default case here: https://github.com/nicklockwood/SwiftFormat/blob/master/Sources/ParsingHelpers.swift#L305-L326
I'm not sure if this is the only case where a function would trigger this bug, but it's the only one I've come across so far.
I am working on fixing this, but thought I may let you know in case you have some ideas of how it would be fixable.
Actually I think this is a pretty simple fix after checking a bit more. The switch is on tokens[prev], which is the end of the generic scope, >. Adding a case .endOfScope(">"): return false has my test passing now and no regressions in the ParsingHelpersTests
@dcramps your suggested fix seems to work - thanks!
@dcramps fixed in 0.44.15. Thanks again!