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

Jean-Daniel mailing at xenonium.com
Thu Jan 11 01:14:15 CST 2018


Let say you have a module that declare a enum and also declare a function that take that enum as parameter and switch over it.

As there is no cross module boundary, the switch don’t require #unknown or any fancy trick to be exhaustive.

Now if you remove the case from the enum, any client code that call your function by passing the enum will cause a crash.

The following is just blind guess as I don’t have any knowledge of the swift compiler, but as Swift cases are not necessarily simple Int, maybe there some times swift has to generates symbols for complex cases.
In such case, removing an enum will be even more harmful as it will cause a crash a start for missing symbol (assuming at such time Apple did switch to dyld3 which bound at launch and not lazily).


> Le 11 janv. 2018 à 01:34, Howard Lovatt <howard.lovatt at gmail.com> a écrit :
> 
> If an enum isn’t final; then what’s the difference in deleting as opposed to adding?
> 
> -- Howard. 
> 
>> On 10 Jan 2018, at 4:13 pm, Jean-Daniel <mailing at xenonium.com> wrote:
>> 
>> 
>> 
>>> Le 10 janv. 2018 à 23:58, Howard Lovatt via swift-evolution <swift-evolution at swift.org> a écrit :
>>> 
>>> Two points:
>>> 
>>> 1. I like Chris’s suggestion of #unknown and in particular that it is distinct from default. 
>>> 
>>> 2. All the discussion is about a framework adding a case, what about when a framework deletes a case?
>> 
>> This is a binary breaking change (just like removing an existing function or method).
>> 
>> 



More information about the swift-evolution mailing list