Skip to content

Nested Linq expression trees result in quotation related calls #2758

@krontogiannis

Description

@krontogiannis

Trying to extract a Linq expression which contains a nested Linq expression results in expression with Quotation related calls.

Repro steps

open System
open System.Linq.Expressions

type LinqExpr =
    static member fromFunc<'T, 'U>(e : Expression<Func<'T, 'U>>) = e

let expr = LinqExpr.fromFunc(fun () -> LinqExpr.fromFunc(fun y -> y + 1))

val it : Expression<Func<unit,Expression<Func<int,int>>>> =
  unitVar0 => fromFunc(QuotationToLambdaExpression(SubstHelper(NewDelegate (Func`2, y, Call (None, op_Addition, [y, Value (1)])), new [] {}, new [] {})))
    {Body = fromFunc(QuotationToLambdaExpression(SubstHelper(NewDelegate (Func`2, y, Call (None, op_Addition, [y, Value (1)])), new [] {}, new [] {})));
     CanReduce = false;
     Name = null;
     NodeType = Lambda;
     Parameters = seq [unitVar0];
     ReturnType = System.Linq.Expressions.Expression`1[System.Func`2[System.Int32,System.Int32]];
     TailCall = false;
     Type = System.Func`2[Microsoft.FSharp.Core.Unit,System.Linq.Expressions.Expression`1[System.Func`2[System.Int32,System.Int32]]];}

Expected behavior

The resulting expression tree should not contain quotation related calls, but probably use an ExpressionType.Quote for the nested expression.

Actual behavior

Expression tree contains this expression tree:

QuotationToLambdaExpression(SubstHelper(NewDelegate (Func`2, y, Call (None, op_Addition, [y, Value (1)])), new [] {}, new [] {}))

Known workarounds

None.

Related information

Provide any related information

  • Windows 10
  • .NET Framework, any version
  • Visual Studio 2015/2017
  • Severity: low

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-QuotationsQuotations (compiler support or library). See also "queries"BugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    In Progress

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions