Seems like odd xcode and/or Swift behavior

I'm writing a little Swift app to report IP addresses that attack my Wordpress websites. I made a little mistake in one file which revealed an xcode behavior which seems like a bug. When I try to Build the code xcode says it failed. A failure message appears in the Issues, but after a few seconds the failure message disappears. No line of code is ever marked as having an issue. But the build definitely fails.

Included here is a little bit of code which illustrates the issue. It is just a struct and closure definition.

If you create a little project and add the code you can try to build it. Cmnd-B is all you need to do. Sometimes the error message doesn't even appear in Issues at all even though the Build fails. Just try Cmnd-B a couple times and you should see it appear for a few seconds.

Can you spot the error in this code? There is an errant return statement in the closure. Change in return to just in and is should build OK.

But what is going on with the transient Build error message that disappears and the failure to mark any lines of code? Is this not an xcode/swift bug?

I'm using xcode 14.2 and the latest Swift.

import Foundation

class weirdBehavior: NSObject {

    //  Construct a struct which defines the data to be saved for each reported bad IP
    //  This struct is used to generate JSON strings.
    struct savedBadIP: Codable {
        var ip: String
        var reason: String
        var attackDateString: String
        var reportedDateString: String
        var responseError: Bool
        var responseConfidence: Int
        var responseDetail: String
    }

    func weirdBehaviorExample() {

        let dateFormatter = DateFormatter()

        let checkForRecentDate : (savedBadIP, savedBadIP) -> Bool = {badIP1, badIP2 in return
            let date1 = dateFormatter.date(from:  badIP1.reportedDateString)!
            let date2 = dateFormatter.date(from:  badIP2.reportedDateString)!
            let diff: TimeInterval = date2.timeIntervalSince(date1)
            return diff < 0.0           // Return false if date2 is before date1
            }
    }
}