<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 12, 2016, at 1:24 PM, Dmitri Gribenko via swift-dev &lt;<a href="mailto:swift-dev@swift.org" class="">swift-dev@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>"%select{variable|constant}2 %0 inferred to have type %1, "</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>"which may be unexpected"</div><div class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>no_throw_in_try</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>"no calls to throwing functions occur within 'try' expression"</div><div class="">&nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>no_throw_in_do_with_catch</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp;<span class="Apple-converted-space">&nbsp;</span>"'catch' block is unreachable because no errors are thrown in 'do' block"</div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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="">It seems like some of these can be too pedantic in cross-platform code bases because of #if's that are not analyzable and might need more granular suppression mechanisms. &nbsp; For example:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 class="">func foo() throws {}</div><div class="">func bar() {}</div><div class=""><br class=""></div><div class="">func baz() {</div><div class="">&nbsp; do {</div><div class="">#if os(OSX)</div><div class="">&nbsp; &nbsp; try foo()</div><div class="">#else</div><div class="">&nbsp; &nbsp; bar()</div><div class="">#endif</div><div class="">&nbsp; &nbsp; // common code.</div><div class="">&nbsp; } catch { // on non-OS X,&nbsp;warning: 'catch' block is unreachable because no errors are thrown in 'do' block</div><div class="">&nbsp; &nbsp; // ...</div><div class="">&nbsp; }</div><div class="">}</div></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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 class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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="">I definitely remember we had some similar issues in the standard library or tests, but don't remember the specifics.</div></div></blockquote><br class=""></div><div>FWIW, one of the reasons we build an AST for disabled #if regions is so we can be smart about this sort of thing. &nbsp;The fact that we don’t for this warning is a bug in the warning, not something we should use warning suppression to fix.&nbsp;</div><div><br class=""></div><div>To give you an example of this in action, we currently warn on this:</div><div><br class=""></div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> f() -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> x = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">42 &nbsp; //&nbsp;</span><span style="font-family: Monaco; font-size: 10px; color: rgb(213, 59, 211);" class="">warning: </span><span style="font-family: Monaco; font-size: 10px;" class="">variable 'x' was never mutated; consider changing to 'let' constant</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div><br class=""></div><div>but are smart enough to not warn on this:</div><div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> f() -&gt; <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> x = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">42</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #78492a" class="">#if</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>false</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">&nbsp; x = <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">12</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(120, 73, 42);" class="">#endif</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; </span>return<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> x</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><div style="font-family: Helvetica; font-size: 12px;"><br class=""></div>We should do the same for catch blocks that have a try in a disabled region.<br class=""><br class="">-Chris<div style="font-family: Menlo; font-size: 11px;" class=""><br class=""></div></div></div></body></html>