[swift-evolution] Handling unknown cases in enums [RE: SE-0192]

Chris Lattner clattner at nondot.org
Fri Jan 12 01:30:29 CST 2018


> On Jan 11, 2018, at 11:15 PM, Jean-Daniel via swift-evolution <swift-evolution at swift.org> wrote:
> 
> A question about the new #unknown behavior. Is it intended to be used for error handling too ?
> Will it be possible to use in catch clause ?

If we go with the #unknown approach, then yes of course it will work in catch clauses.  They are patterns, so it naturally falls out.

If we go with the “unknown default:” / “unknown case:"  approach, then no, this has nothing to do with error handling.

IMO, this pivots on the desired semantics for “unknown cases in enums”: if you intentionally try to match on this, do we get a warning or error if you don’t handle all the cases?  If we can get to consensus on that point, then the design is pretty obvious IMO.

-Chris



More information about the swift-evolution mailing list