Referring to static variable of protocol via KeyPath leads to nonzero exit code

While I was messing around with keypaths, I ran into this issue:

protocol Foo {
    static var value: Int { get }
}

let keypath: KeyPath<any Foo.Type, Int> = \.value // Doesn't compile

If I try to create a keypath of value KeyPath<any Foo.Type, Int>, it doesn't compile. It gives me Command SwiftCompile failed with a nonzero exit code error.

Should I report this to swift or swift-build?

I came across this issue about key paths not being able to express static members but it doesn't seem to an issue anymore (it hasn't been marked solved for some reason, maybe an edge case?).

i believe that crash is bug, and should be filed against the compiler here

Done.

1 Like

It was reported before and closed, the original issue now reopened.

That was an accident, I meant to mark your bug as a dupe of the original but I closed the original one instead. The original one is still open.

2 Likes