<div dir="ltr">Hi all,<br><br>I&#39;m fixing <font face="monospace, monospace">#if</font> condition processing in this PR<br><div><a href="https://github.com/apple/swift/pull/7955">https://github.com/apple/swift/pull/7955</a><br><br>It resolves these issues:</div><div><br><div><b>A) <a href="https://bugs.swift.org/browse/SR-3663">SR-3663</a>: Precedence of &#39;&amp;&amp;&#39; and &#39;||&#39; and short-circuit rule of them.<br></b><br><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)">#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">false</span> || true &amp;&amp; false<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)">  print(&quot;true&quot;)</span>
<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span></pre><div><br></div><div>This used to evaluate to &#39;<font face="monospace, monospace">true</font>&#39;.</div><div><br></div><b>B) <a href="https://bugs.swift.org/browse/SR-4032">SR-4032</a>: Version check with binary operator.<br></b><br><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)">#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">swift</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&gt;=</span><span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">5.0</span>) <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">&amp;&amp;</span> FOO
  Some Swift <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">5</span> code here
#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span></pre><div><br></div><div>I believe, this block should not be parsed.</div><div><br></div><b>C) <a href="https://bugs.swift.org/browse/SR-3663">SR-3663</a>: Invalid condition after short-circuit binary operator.<br></b><br><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)">#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">||</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">true</span> * This is not &lt;acceptable&gt;!
#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span></pre><div><br></div><div>This used to be accepted.</div><div><br></div><b>D) <a href="https://bugs.swift.org/browse/SR-4031">SR-4031</a>: Compound name in the condition<br></b><br><div><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)">#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> FOO(_:)
#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">elseif</span> os(foo:)(macOS)
#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">elseif</span> os(Linux(foo:bar:))
#<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span></pre><br></div></div></div><div>This used to be accepted.</div><div><br></div><div>In the PR, I keep A) and B) behavior in <font face="monospace, monospace">-swift-version 3</font> mode.</div><div>However, as for C) and D), I don&#39;t think it&#39;s worth to keep them even in Swift3 mode, because they are obviously wrong.</div><div><br></div><div>What do you think? Do we need accept them in Swift3 mode?</div></div>