Hi there, 

I see a new warning message for switch statements on enums, like this one: 

enum Test {

    case one(Any)

    case two

}


let x: Test = .one("One")

switch x {

    case .one(let s as String): print(s)

    case .one: break

    case .two: break

}


enum.swift:9:10: warning: case is already handled by previous patterns; consider removing it

    case .one: break 



I do not see this warning with the 04-24 dev snapshot. 

The warning goes away with the use of the wildcard pattern in the second case:

switch x {

    case .one(let s as String): print(s)

    case .one(_): break

    case .two: break

}



I am wondering if this change is intentional, though it does make sense to me. Can someone please point me to the related commit?

Thanks in advance!

Pushkar N Kulkarni,
IBM Runtimes

Simplicity is prerequisite for reliability - Edsger W. Dijkstra


_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to