Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LeafExpressionConverter ignores ValueTuple and assumes System.Tuple #6515

Closed
kevmal opened this issue Apr 12, 2019 · 0 comments
Closed

LeafExpressionConverter ignores ValueTuple and assumes System.Tuple #6515

kevmal opened this issue Apr 12, 2019 · 0 comments
Labels
Area-Library Issues for FSharp.Core not covered elsewhere Bug
Milestone

Comments

@kevmal
Copy link
Contributor

kevmal commented Apr 12, 2019

https://github.com/Microsoft/visualfsharp/blob/0058f88769ab1585c131680eb94a33cf37a71438/src/fsharp/FSharp.Core/Linq.fs#L748-L757

For example

FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.QuotationToExpression(<@struct(1,1)@>)

outputs

val it : Expression =
  new Tuple`2(1, 1) {Arguments = seq [1; 1];
                     CanReduce = false;
                     Constructor = Void .ctor(Int32, Int32);
                     Members = null;
                     NodeType = New;
                     Type = System.Tuple`2[System.Int32,System.Int32];}

So things like

let f (struct(a,b)) = (a,b)
FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.QuotationToExpression(<@f struct(1,1)@>)

raises the exception

> System.ArgumentException: Expression of type 'System.Tuple`2[System.Int32,System.Int32]' cannot be used for parameter of type 'System.ValueTuple`2[System.Int32,System.Int32]' of method 'System.Tuple`2[System.Int32,System.Int32] f[Int32,Int32](System.ValueTuple`2[System.Int32,System.Int32])'
   at System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi)
   at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments)
   at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments)
   at Microsoft.FSharp.Linq.RuntimeHelpers.LeafExpressionConverter.ConvExprToLinqInContext(ConvEnv env, FSharpExpr inp)
   at <StartupCode$FSI_0019>.$FSI_0019.main@()
Stopped due to error
@cartermp cartermp added Area-Library Issues for FSharp.Core not covered elsewhere Bug labels Apr 12, 2019
@cartermp cartermp added this to the 16.1 milestone Apr 12, 2019
@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@cartermp cartermp closed this as completed Jul 5, 2019
@cartermp cartermp modified the milestones: Backlog, 16.3 Jul 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Library Issues for FSharp.Core not covered elsewhere Bug
Projects
None yet
Development

No branches or pull requests

2 participants