title: Error: Unexpected infix operator in expression, about a successfully compiled prefix operator
body: <p>Playing around a little bit with infix operators, I was surprised about the following:</p>
  
  <pre><code>let (&gt;~~~) = function null -&gt; String.Empty | s -&gt; s  // compiles fine, see screenshot
  match &gt;~~~ input with .... // error: Unexpected infix operator in expression
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xr1sy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xr1sy.png" alt="val (&gt;~~~) : string -&gt; string)"></a></p>
  
  <p>and:</p>
  
  <p><a href="https://i.stack.imgur.com/OkDHx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OkDHx.png" alt="Unexpected infix operator"></a></p>
  
  <p>Changing the first characters of the <em>prefix</em> operator (to <code>!~~~</code> for instance) fixes it. That I get an error that the <em>infix</em> operator is unexpected is rather weird. Hovering shows the definition to be <code>string -&gt; string</code>.</p>
  
  <p>I'm not too surprised about the error, F# requires (iirc) that the first character of a prefix operator must itself be one of the predefined prefix operators. But why does it compile just fine, and when I use it, the compiler complains?</p>
  
  <p>Update: the F# compiler seems to know in other cases just fine when I use an invalid character in my operator definition, it says <em>"Invalid operator definition. Prefix operator definitions must use a valid prefix operator name."</em></p>
  
  <p><a href="https://i.stack.imgur.com/AApk9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AApk9.png" alt="Invalid operator definition."></a></p>