<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="">I support this proposal 100%. In fact, I just ran into this use case.&nbsp;<div class=""><br class=""></div><div class="">I’d support extending it to allow partial-case coverage (as long as it doesn’t cross a case: boundary, obviously), e.g.</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">switch</span><span style="font-variant-ligatures: no-common-ligatures" class=""> result {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .success(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> object):</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; doSomething(with: object)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">case</span><span style="font-variant-ligatures: no-common-ligatures" class=""> .error(</span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">let</span><span style="font-variant-ligatures: no-common-ligatures" class=""> error):</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">#if</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">debug</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; alertUser(error)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(120, 73, 42);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" class="">#endif</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; handleError(error)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">I don’t see a reason to prevent that, but if we can just get the current proposal (full cases only) in Swift 4 I’ll be satisfied and just put this on my (large and growing) list of things to bring up for 5.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 10, 2017, at 6:28 AM, rintaro ishizaki 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 dir="ltr" class=""><div class="">Here's proposal link:</div><a href="https://github.com/rintaro/swift-evolution/blob/conditional-switch-case/proposals/NNNN-conditional-switch-case.md" class="">https://github.com/rintaro/swift-evolution/blob/conditional-switch-case/proposals/NNNN-conditional-switch-case.md</a><br class=""><div class=""><br class=""></div><div class="">Fixed some typos, including my name :)</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">2017-05-10 17:32 GMT+09:00 rintaro ishizaki <span dir="ltr" class="">&lt;<a href="mailto:fs.output@gmail.com" target="_blank" class="">fs.output@gmail.com</a>&gt;</span>:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi evolution community,<div class=""><br class=""></div><div class="">This proposal allows you to enclose switch cases with #if directive.<br class=""></div><div class="">Implementation: <a href="https://github.com/apple/swift/pull/9457" target="_blank" class="">https://github.com/apple/<wbr class="">swift/pull/9457</a></div><div class="">This is one of the oldest SR issue:</div><div class=""><a href="https://bugs.swift.org/browse/SR-2" target="_blank" class="">https://bugs.swift.org/browse/<wbr class="">SR-2</a></div><div class=""><a href="https://bugs.swift.org/browse/SR-4196" target="_blank" class="">https://bugs.swift.org/browse/<wbr class="">SR-4196</a></div><div class=""><br class=""></div><div class="">Thanks!</div><div class="">Rintaro</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><h1 style="box-sizing:border-box;margin:0px 0px 16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class="">Allow&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:inherit;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if</code>&nbsp;to guard switch case clauses</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class=""><li style="box-sizing:border-box" class="">Proposal:&nbsp;<a href="https://gist.github.com/rintaro/NNNN-filename.md" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">SE-NNNN</a></li><li style="box-sizing:border-box;margin-top:0.25em" class="">Authors:&nbsp;<a href="https://github.com/rintaro" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">Rintaro Ishziaki</a></li><li style="box-sizing:border-box;margin-top:0.25em" class="">Review Manager: TBD</li><li style="box-sizing:border-box;margin-top:0.25em" class="">Status:&nbsp;<span style="box-sizing:border-box;font-weight:600" class="">Awaiting review</span></li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_-5841035384072243354gmail-user-content-introduction" class="m_-5841035384072243354gmail-anchor" href="https://gist.github.com/rintaro/a5a9d9836027d7df7a5326a3a8cf9d89#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">This proposal adds ability to guard switch&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">case</code>&nbsp;clauses with&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if</code>&nbsp;directives.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none" target="_blank" class="">Not yet</a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_-5841035384072243354gmail-user-content-motivation" class="m_-5841035384072243354gmail-anchor" href="https://gist.github.com/rintaro/a5a9d9836027d7df7a5326a3a8cf9d89#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">When you want to switch cases only for certain compilation condition, say switching&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if os(Linux)</code>&nbsp;guarded enum cases, right now you have to write&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">switch</code>&nbsp;twice:</p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class=""><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">Operation</span> {
  <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">output</span>(<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">String</span>)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">os</span>(<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Linux</span>)
  <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">syscall</span>(Syscall)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
}

<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">execute</span>(<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">operation</span></span>: Operation) {
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> !<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">os</span>(<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Linux</span>)
   <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> operation {
   <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">output</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
       <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">print</span>(str)
   }
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span>
   <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> operation {
   <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">output</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
       <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">print</span>(str)
   <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">syscall</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> call)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
       call.<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">execute</span>()
   }
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">This is annoying and error prone.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_-5841035384072243354gmail-user-content-proposed-solution" class="m_-5841035384072243354gmail-anchor" href="https://gist.github.com/rintaro/a5a9d9836027d7df7a5326a3a8cf9d89#proposed-solution" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Proposed solution</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">This proposal allows&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if</code>&nbsp;to guard switch case clauses.</p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class=""><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">execute</span>(<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">operation</span></span>: Operation) {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> operation {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">output</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">print</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">os</span>(<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Linux</span>)
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">syscall</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> call)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        call.<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">execute</span>()
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
    }
}</pre></div><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_-5841035384072243354gmail-user-content-detailed-design" class="m_-5841035384072243354gmail-anchor" href="https://gist.github.com/rintaro/a5a9d9836027d7df7a5326a3a8cf9d89#detailed-design" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a>Detailed design</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">This change shouldn't affect existing&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if</code>&nbsp;directives&nbsp;<em style="box-sizing:border-box" class="">within</em><wbr class="">&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">case</code>&nbsp;clauses. This code should works as expected:</p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class=""><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">foo</span>(<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">x</span></span>: MyEnum) {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> PRINT_SOME
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">print</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">other</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doOther</span>()
    }
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Only if the next token after&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">#if</code>&nbsp;is&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">case</code>&nbsp;or&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">default</code>, the Parser treat it as guarding&nbsp;<code style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;padding:0.2em 0px;margin:0px;background-color:rgba(27,31,35,0.05);border-radius:3px" class="">case</code>&nbsp;clauses.</p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class=""><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">foo</span>(<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">x</span></span>: MyEnum) {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> HAS_OTHER
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">other</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doOther</span>()
    }
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
}</pre></div><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class=""><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">foo</span>(<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)"><span class="m_-5841035384072243354gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">x</span></span>: MyEnum) {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> HAS_OTHER
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">default</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">break</span>
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
}</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">Error cases:</p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class="">    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> HAS_OTHER
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">other</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doOther</span>()
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doMore</span>() <span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box">//</span> error: all statements inside a switch must be covered by a 'case' or 'default'</span>
<span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">endif</span>
    }</pre></div><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class="">    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> HAS_OTHER
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doMore</span>()
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">other</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doOther</span>() <span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box">//</span> error: 'case' label can only appear inside a 'switch' statement</span>
<span class="m_-5841035384072243354gmail-pl-c" style="box-sizing:border-box;color:rgb(150,152,150)"></span>#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span>
    }</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(36,41,46)" class=""><span style="font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px" class="">You can guard multiple cases as long as it is guarding whole clauses</span><font face="-apple-system, system-ui, segoe ui, helvetica, arial, sans-serif, apple color emoji, segoe ui emoji, segoe ui symbol" class=""><span style="font-size:16px" class="">:</span></font></p><div class="m_-5841035384072243354gmail-highlight m_-5841035384072243354gmail-highlight-source-swift" style="box-sizing:border-box;margin-bottom:16px;color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;;font-size:16px"><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" class="">    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> x {
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">some</span>(<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> str)<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doSomething</span>(str)
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> HAS_OTHERS
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">other</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doOther</span>()
    <span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_-5841035384072243354gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">more</span><span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span>
        <span class="m_-5841035384072243354gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">doMore</span>()
#<span class="m_-5841035384072243354gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">else</span>
    }</pre><div class=""><br class=""></div></div><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom:1px solid rgb(234,236,239);color:rgb(36,41,46);font-family:-apple-system,system-ui,&quot;segoe ui&quot;,helvetica,arial,sans-serif,&quot;apple color emoji&quot;,&quot;segoe ui emoji&quot;,&quot;segoe ui symbol&quot;" class=""><a id="m_-5841035384072243354gmail-user-content-source-compatibility" class="m_-5841035384072243354gmail-anchor" href="https://gist.github.com/rintaro/a5a9d9836027d7df7a5326a3a8cf9d89#source-compatibility" style="box-sizing:border-box;background-color:transparent;color:rgb(3,102,214);text-decoration-line:none;float:left;padding-right:4px;line-height:1" target="_blank"></a></h2></div></div>
</blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>