Comparable

Trying to compile my existing Swift code in Silver. This is the original code:

public func <(left: Time, right: Time) -> Bool {
    return left.hours < right.hours || (left.hours == right.hours && left.minutes < right.minutes)
}

public func ==(left: Time, right: Time) -> Bool {
    return left.hours == right.hours && left.minutes == right.minutes
}

public struct Time: Comparable {
    
    public var hours: Int = 127
    public var minutes: Int = 127
    
    public init() {
    }
    
    public func isValid() -> Bool {
        return hours != 127 && minutes != 127
    }
    
}

If I recall correctly, the comparison functions need to be defined within the class/struct in Silver (unless that changed in the past few months). I assume this would be the Silver way, but it does not compile:

public struct Time: Comparable {
    
    static func <(_ lhs: Time, _ rhs: Time) -> Bool {
        return false
    }
    static func <=(_ lhs: Time, _ rhs: Time) -> Bool {
        return false
    }
    static func >=(_ lhs: Time, _ rhs: Time) -> Bool {
        return false
    }
    static func >(_ lhs: Time, _ rhs: Time) -> Bool {
        return false
    }
    
    public var hours: Int = 127
    public var minutes: Int = 127
    
    public init() {
    }
    
    public func isValid() -> Bool {
        return hours != 127 && minutes != 127
    }
    
}

(I get the error message with the typo that was mentioned in Typo in error message)

It seems Comparable is defined as implementing Equatable, which therefore requires implementing func ==(...). I assume the typo-free error message would actually point this out.

In other words, this compiles:

public struct Time: Comparable {
    
    #if ELEMENTS
    static func ==(_ lhs: Time, _ rhs: Time) -> Bool {
        return lhs.hours == rhs.hours && lhs.minutes == rhs.minutes
    }
    static func <(_ lhs: Time, _ rhs: Time) -> Bool {
        return lhs.hours < rhs.hours || (lhs.hours == rhs.hours && lhs.minutes < rhs.minutes)
    }
    static func <=(_ lhs: Time, _ rhs: Time) -> Bool {
        return lhs < rhs || lhs == rhs
    }
    static func >=(_ lhs: Time, _ rhs: Time) -> Bool {
        return !(lhs < rhs)
    }
    static func >(_ lhs: Time, _ rhs: Time) -> Bool {
        return !(lhs <= rhs)
    }
    #endif
    
    public var hours: Int = 127
    public var minutes: Int = 127
    
    public init() {
    }
    
    public func isValid() -> Bool {
        return hours != 127 && minutes != 127
    }
    
}