Ambiguity in pattern matching syntax : <p>I came across an oddity in the F# pattern matching syntax today, which can lead to apparent failures in the exhaustivity check.</p>

<pre><code>type Thing =
    | This
    | That
    | Other

let useThing =
    function
    | This -&gt; "A"
    | That -&gt; "A"
    | That -&gt; "B" // compiler complains
    | Other -&gt; "B"
</code></pre>

<p>In the above scenario the compiler helpfully tells me that the second That rule will never be matched. However, if I had tried to make the code a bit more compact and had written</p>

<pre><code>let useThing =
    function
    | This | That -&gt; "A"
    | That | Other -&gt; "B"    
</code></pre>

<p>I do not get any help from the compiler. I <em>think</em> the reason is that <code>| This | That -&gt;. "A"</code> is not a shortcut for <code>| This -&gt; "A" | That -&gt; "A"</code>, even though it looks very much like it is (and I've seen many code samples that treat it as such). Instead, from what I can find, the pipe symbol is used both to separate individual patterns, and also as OR pattern.</p>

<p>This is not a big issue for most DUs, but I encountered the problem when mapping a DU with a large number of cases into another DU with a small number of cases. My attempt to use the shortcut syntax caused a bug.</p>

<p>So my questions are:</p>

<ol>
<li>Is my interpretation correct?</li>
<li>Is there any workaround apart from listing each pattern on a separate line?</li>
</ol>
