function-local struct def can never be Comparable?

If i have a struct inside a function, swift keeps telling me is doesn't conform to Comparable, even though the same definition is fine outside of a function -- why is this?

Foo fails Comparable here:

func foo() {
            struct Foo : Equatable, Comparable {
                let x: Int
                let y: Int
                static func < (lhs: Foo, rhs: Foo) -> Bool {
                    return lhs.x+lhs.y < rhs.x+rhs.y
                }
            }
        }

Replies

even though the same definition is fine outside of a function

Your code lacks the definition of ==, so it is not fine even in outside of a function.

Code Block
func foo() {
struct Foo : Equatable, Comparable {
let x: Int
let y: Int
static func < (lhs: Foo, rhs: Foo) -> Bool {
return lhs.x+lhs.y < rhs.x+rhs.y
}
static func == (lhs: Foo, rhs: Foo) -> Bool {
return lhs.x+lhs.y == rhs.x+rhs.y
}
}
}

I can find Swift compiler shows error even with this code, but the same definition is fine outside of a function would be needed to state that something weird is going on.

I could not find why nor what some notes added to the error message mean, like `Candidate would match if 'Foo' conformed to 'FloatingPoint' and so on.


You should better ask in the forums.swift.org, or send a bug report to bugs.swift.org .
Thanx -- i've asked on forums.swift.org

Confirmed - it's a known bug. SR-3092
Thanks for sharing the info.