<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><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 9:55 PM, Peter Dillinger via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class="">Missing 'try' is a fatal issue?<br class=""></blockquote><br class="">That could be argued I suppose, I was referring to unreachable code, unused variables,<br class="">variables that are never mutated, etc.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">And what about non-exhaustive switch?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Both of these existing rules seem to violate the principle claimed, because they are hazards to incomplete or experimental changes that might lead people to use quick fixes (try!; default) that are not associated with a warning, whereas a warning instead of the error would (as you claim) signal to the user there are pending fixes before commit.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></div></blockquote><br class=""></div><div>Here's a different principle: When Swift generates a warning, the mistake has no runtime effect on the behavior of the code, but things like non-exhaustive `switch` or a missing `try` represent code where you haven't told the compiler how to handle some of the circumstances it might encounter.</div><div><br class=""></div><div>If you stick a `return` in the middle of some code, the compiler knows exactly how to interpret that: Return there and don't run the code after it. If you write a non-exhaustive `switch`, what is the compiler supposed to do? Fall out of `switch` statement? Trap? It's unclear. Similarly, if there's no `try`—particularly outside of a `do`/`catch` block or `throws` function—what behavior should the compiler assume you want?</div><div><br class=""></div><div>Trapping is clearly the proper choice, because Swift's philosophy is to trap whenever the program finds itself in a state that the programmer did not anticipate. And yet you don't want the *lack* of something to cause a trap; you should at least be able to see the operation so you have a chance to recognize the potential to trap. (Implicitly unwrapped optionals are the exception that proves the rule--many programmers ban them because they cause invisible trapping. You don't want people banning `switch` or `throw` statements because of their invisible danger.) Any other option, though, runs the risk of letting a program run off the rails and do the wrong thing.</div><div><br class=""></div><div>So we emit an error in these cases because the programmer has written ambiguous code, and the compiler has no good option for resolving the ambiguity. On the other hand, if you use `var` instead of `let`, or write code after a `return`, the instructions your code is giving the compiler are unambiguous; they're just not phrased as well as they could be. So we emit a program that does what your code says and politely point out that you could write it better.</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-position: normal; font-variant-numeric: normal; font-variant-alternates: normal; font-variant-east-asian: normal; line-height: normal; border-spacing: 0px;"><div class=""><div style="font-size: 12px; " class="">--&nbsp;</div><div style="font-size: 12px; " class="">Brent Royal-Gordon</div><div style="font-size: 12px; " class="">Architechies</div></div></span>

</div>
<br class=""></body></html>