Closed jpsim closed 3 months ago
Hey @jpsim! For some reason these diagnostics are really thorny, and probably warrant some bug reports to Swift. For example, this compiles without warning:
func never<A>(never: Never) -> A {}
enum Foo {}
func never<A>(never: Foo) -> A {}
So I think technically this should compile, but it doesn't:
enum Never {
static subscript<A>(never: Foo) -> A {
}
I'll file a bug soon.
Ideally we'd be able to have the implementation of this subscript regardless, since we eventually want to abstract it on the CasePathable
protocol. We're just delaying that work, probably to 2.0, since it feels like a breaking change to folks with manual conformances.
I have found that omitting the return
statement and still returning \.never
silences the warning, though:
public subscript(root: Foo) -> PartialCaseKeyPath<Foo> {
- return \.never
+ \.never
Can you try making that change and confirm?
Thanks for the details! I'll give that a shot.
Fixes warnings due to unreachable code introduced in 1.4.0:
For example:
Produces this expansion (compiler warnings added as code comments by me)
We can fix this warning by simply not producing the subscript definition when the enum has no cases.