title: Issue while building dynamic Expression Tree
body: <p>I am trying to build a dynamic Expression Tree like below : </p>
  
  <pre><code> Func&lt;IEnumerable&lt;int&gt;, int, bool&gt; dividesectionmethod = (x, y) =&gt;
              {
                  int nos1 = 0;
                  int nos2 = 0;
                  foreach (int i in x)
                  {
                      if (i &lt;= y)
                          nos1++;
                      else
                          nos2++;
                  }
                  return nos1 &gt; nos2;
              };
  </code></pre>
  
  <p>For that I am using :</p>
  
  <pre><code> ParameterExpression enumerableExpression = Expression.Parameter(typeof(IEnumerable&lt;int&gt;), "x");
              ParameterExpression intexpression = Expression.Parameter(typeof(int), "y");
  
              ParameterExpression localvarnos1 = Expression.Variable(typeof(int), "nos1");
              ParameterExpression localvarnos2 = Expression.Variable(typeof(int), "nos2");
              ConstantExpression zeroConstantintval = Expression.Constant(0);
              BinaryExpression bexplocalnos1 = Expression.Assign(localvarnos1, zeroConstantintval);
              BinaryExpression bexplocalnos2 = Expression.Assign(localvarnos2, zeroConstantintval);
  
              //As Expression does not support Foreach we need to get Enumerator before doing loop
  
              ParameterExpression enumerator = Expression.Variable(typeof(IEnumerator&lt;int&gt;), "enumerator");
              BinaryExpression assignenumerator = Expression.Assign(enumerator, Expression.Call(enumerableExpression, typeof(IEnumerable&lt;int&gt;).GetMethod("GetEnumerator")));
  
  
              var currentelement = Expression.Parameter(typeof(int), "i");
              var callCurrent = Expression.Assign(currentelement, Expression.Property(enumerator, "Current"));
  
              BinaryExpression firstlessequalsecond = Expression.LessThanOrEqual(currentelement, intexpression);
  
              MethodCallExpression movenext = Expression.Call(enumerator, typeof(IEnumerator).GetMethod("MoveNext"));
  
              LabelTarget looplabel = Expression.Label("looplabel");
              LabelTarget returnLabel = Expression.Label(typeof(bool), "retval");
  
              BlockExpression block = Expression.Block(enumerableExpression, intexpression, localvarnos1, localvarnos2,
                  bexplocalnos1, bexplocalnos2, Expression.Loop(Expression.IfThenElse(
                  Expression.NotEqual(movenext, Expression.Constant(false)),
                  Expression.IfThenElse(firstlessequalsecond, Expression.Increment(localvarnos1), Expression.Increment(localvarnos2)),Expression.Break(looplabel)), looplabel),
                  Expression.Return(returnLabel, Expression.LessThan(localvarnos1, localvarnos2)));
  
              Expression&lt;Func&lt;IEnumerable&lt;int&gt;, int, bool&gt;&gt; lambda = Expression.Lambda&lt;Func&lt;IEnumerable&lt;int&gt;, int, bool&gt;&gt;(block, Expression.Parameter(typeof(IEnumerable&lt;int&gt;), "x"),
                  Expression.Parameter(typeof(int), "y"));
  
  
              Func&lt;IEnumerable&lt;int&gt;, int, bool&gt; mymethod = lambda.Compile();
  </code></pre>
  
  <p>But the problem is Expression.Lambda throws an exception :</p>
  
  <pre><code>Expression of type 'System.Void' cannot be used for return type 'System.Boolean'
  </code></pre>
  
  <p>I dont know the issue as my block seems to be Ok:</p>
  
  <pre><code>.Block() {
      $x;
      $y;
      $nos1;
      $nos2;
      $nos1 = 0;
      $nos2 = 0;
      .Loop  {
          .If (.Call $enumerator.MoveNext() != False) {
              .If ($i &lt;= $y) {
                  .Increment($nos1)
              } .Else {
                  .Increment($nos2)
              }
          } .Else {
              .Break looplabel { }
          }
      }
      .LabelTarget looplabel:;
      .Return retval { $nos1 &lt; $nos2 }
  }
  </code></pre>
  
  <p>Please let me know what the problem could be. </p>