<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I wouldn’t recommend this in general. This will just make resiliently linked programs incredibly unstable. There’s often something better that can be done, but it requires thinking about your particular case and the particular enum.</div><div class=""><br class=""></div><div class="">* ignore what you don’t understand (or care about)</div><div class="">* map it to a less good but ultimately correct generic handler</div><div class="">* throw</div><div class="">* forward it</div><div class="">* call a method on the enum itself to handle it</div><div class=""><br class=""></div><div class="">Ultimately it’s much the same as the default case for a throw.</div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 29, 2016, at 2:25 AM, Zhao Xin via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">It will be better to use `fatalError()` in `default` part that you think never be needed.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default"><font face="georgia, serif" class="">default:</font><br class=""></div><div class="gmail_default"><font face="georgia, serif" class="">fatalError("This should never happen!")</font></div><div class="gmail_default"><font face="georgia, serif" class=""><br class=""></font></div><div class="gmail_default"><font face="georgia, serif" class="">Zhaoxin</font></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Nov 29, 2016 at 11:25 AM, Dave Abrahams via swift-dev <span dir="ltr" class=""><<a href="mailto:swift-dev@swift.org" target="_blank" class="">swift-dev@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
on Sun Nov 27 2016, Slava Pestov <<a href="http://swift-dev-AT-swift.org" class="">swift-dev-AT-swift.org</a>> wrote:<br class="">
<br class="">
>> On Nov 27, 2016, at 4:32 PM, David Sweeris via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>> wrote:<br class="">
>><br class="">
>>><br class="">
>>> On Nov 26, 2016, at 5:25 PM, Robert Widmann via swift-dev <<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">
</span><div class=""><div class="h5">> <mailto:<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>>> wrote:<br class="">
>>><br class="">
><br class="">
>>> Hello all,<br class="">
>>><br class="">
>>> I’ve seen and been a part of a number of conversations recently where talk of planning for “resilient enums”, or even just authors that ship frameworks that will eventually offer a binary option that export enum-based APIs. The consensus seems to be that the only safe way to deal with this situation is to always cover a `switch` statement with a default, regardless of whether the totality checker thinks you’ve covered all cases. Currently, the compiler warns when this is the case, as in stdlib<br class="">
>>><br class="">
>>> extension ProcessTerminationStatus {<br class="">
>>> var isSwiftTrap: Bool {<br class="">
>>> switch self {<br class="">
>>> case .exit(_):<br class="">
>>> return false<br class="">
>>> case .signal(let signal):<br class="">
>>> return CInt(signal) == SIGILL || CInt(signal) == SIGTRAP<br class="">
>>> default:<br class="">
>>> // This default case is needed for standard library builds where<br class="">
>>> // resilience is enabled<br class="">
>>> return false<br class="">
>>> }<br class="">
>>> }<br class="">
>>> }<br class="">
>>><br class="">
>>> I think this warning doesn’t actually serve a purpose and I’d like to remove it, or at the very<br class="">
> least curb it. Currently, I see three paths forward:<br class="">
>>><br class="">
>>> 1) Do nothing.<br class="">
>>> 2) Completely remove the diagnostic<br class="">
>>> 3) Only emit the diagnostic when the case-tree is switching over enum(s) declared inside the<br class="">
> current module.<br class="">
>><br class="">
>> Has the “resilient enum” thing been finalized, or is this kind of code just a preventative<br class="">
> measure?<br class="">
>><br class="">
>> Also, if “resilience” is a compiler flag, there's a fourth option: Disable the warning on builds<br class="">
> that have “resilience” enabled.<br class="">
><br class="">
> The warning is already gone (and the default cause is required) when<br class="">
> the standard library and overlays are built with resilience<br class="">
> enabled. The issue is that resilience is off by default.<br class="">
><br class="">
> I agree the warning is annoying; we should figure out something.<br class="">
<br class="">
</div></div>There should also be a way to write code that will compile without<br class="">
warnings whether or not you have resilience enabled. ;-)<br class="">
<span class="HOEnZb"><font color="#888888" class=""><br class="">
--<br class="">
-Dave<br class="">
</font></span><div class="HOEnZb"><div class="h5"><br class="">
______________________________<wbr class="">_________________<br class="">
swift-dev mailing list<br class="">
<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" rel="noreferrer" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-dev</a><br class="">
</div></div></blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-dev mailing list<br class=""><a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-dev<br class=""></div></blockquote></div><br class=""></body></html>