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

Expression tree with anonymous type created incorrectly #11127

Open
NetMage opened this issue Feb 17, 2021 · 1 comment
Open

Expression tree with anonymous type created incorrectly #11127

NetMage opened this issue Feb 17, 2021 · 1 comment
Labels
Area-Quotations Quotations (compiler support or library). See also "queries" Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Milestone

Comments

@NetMage
Copy link

NetMage commented Feb 17, 2021

Please provide a succinct description of the issue.

Consider

let src = [0..10].Select(fun n -> {| n = n |}).ToList().AsQueryable()

let q1 = src.Select(fun c -> {| z = c.n; b = c.n |})
printfn "%A" q1.Expression

let q2 = src.Select(fun c -> {| b = c.n; z = c.n |})
printfn "%A" q2.Expression

Provide the steps required to reproduce the problem:

  1. Run the program

Expected behavior

Both Expression trees passed to Select should call a two argument constructor for the anonymous type directly.

Actual behavior

The first call to Select creates a nested lambda function call using Invoke instead of just passing the arguments to the constructor.

Known workarounds

Putting the fields in the anonymous record in alphabetical order will correct the error.

Related information

This makes EF Core difficult to use with anonymous records.

  • Windows 10
  • .NET Core 5
  • LINQPad
@cartermp cartermp added Area-Compiler Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code. labels Apr 4, 2021
@cartermp cartermp added this to the Backlog milestone Apr 4, 2021
@cartermp
Copy link
Contributor

cartermp commented Apr 4, 2021

This is related to #6487, but not likely the same issue. I imagine we'd take a fix here even though it's technically a breaking change.

@dsyme dsyme added Area-Queries Query expressions and library implementation Area-Quotations Quotations (compiler support or library). See also "queries" and removed Area-Compiler Area-Queries Query expressions and library implementation labels Mar 31, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Quotations Quotations (compiler support or library). See also "queries" Bug Impact-Low (Internal MS Team use only) Describes an issue with limited impact on existing code.
Projects
Status: New
Development

No branches or pull requests

3 participants