title: Lambda compile failure, reference defined in '' scope, but is not defined
body: <p>In the simple snippet below:</p>
  
  <pre><code>static void Main(string[] args)
  {
      Expression&lt;Func&lt;string, bool&gt;&gt; equal = s =&gt; s == "test";
      LambdaExpression lambda = Expression.Lambda(equal.Body, Expression.Parameter(typeof(string), "s"));
      lambda.Compile();
  }
  </code></pre>
  
  <p>The compile method fails with an <code>InvalidOperationException</code> </p>
  
  <blockquote>
    <p>"variable 's' of type 'System.String' referenced from scope '',
    but it is not defined".</p>
  </blockquote>
  
  <p>While I've found other similar questions, I've failed to understand the answers provided.</p>
  
  <p>The DebugView of the LambdaExpression contains this:</p>
  
  <pre><code>.Lambda #Lambda1&lt;System.Func`2[System.String,System.Boolean]&gt;(System.String $s) {
      $s == "test"
  }
  </code></pre>
  
  <p>So where I've seen in other examples of this question, the parameter and the usage don't match up, this doesn't <em>appear</em> to be an issue here. What am I doing wrong?</p>