You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Quotations: Expr.NewTuple missing options for struct tuples #7914
Is your feature request related to a problem? Please describe.
Quotations seem to be missing a way to construct struct tuples. The Expr.NewTuple constructor will always assume reference tuples. There is no clear workaround, except for splicing into quotation literals (e.g. <@ struct(%x, %y) @>), but that only really works when the types and arity are fixed.
On the other hand, the Patterns.NewTuple active pattern will readily recognize both struct and reference tuple constructors, however the two kinds are not distinguished unless the user performs additional reflection tests on their own.
Describe the solution you'd like
I propose the addition of an Expr.NewStructTuple : Expr list -> Expr constructor. It's a trivial addition which would require adding an isStruct boolean parameter to this internal function.
At the same time, it would probably make sense to expose an equivalent Patterns.NewStructTuple active pattern. To avoid breaking changes, the NewTuple active pattern would still have to recognize struct tuple types.
Activity
dsyme commentedon Jan 10, 2020
Yes, this should be added.
eiriktsarpalis commentedon Jan 13, 2020
I'm looking at the corresponding code in
FSharp.Reflection, and it looks like the public API requires passing theAssemblyinstance containing the System.ValueTuple declarations. I'm assuming this was done to address pre-netcoreapp2.0 runtimes? And if so, is there still a need to reflect a similar api shape inExpr.NewStructTuple : Assembly * Expr list -> Expr?eiriktsarpalis commentedon Nov 5, 2020
Closing since this has already been implemented.