title: Why does this code using yield return compile?
body: <p>As you might expect, this code produces a compiler error:</p>
  
  <pre><code>public static IEnumerable&lt;int&gt; Foo()
  {
  }
  </code></pre>
  
  <blockquote>
    <p>not all code paths return a value</p>
  </blockquote>
  
  <p>However, this compiles with only a warning about unreachable code:</p>
  
  <pre><code>public static IEnumerable&lt;int&gt; Foo()
  {
      if(false)
      {
          yield return 0;
      }
  }
  </code></pre>
  
  <p>This produces an empty enumerable. Why does this work, and is it defined behavior?</p>