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
LINQ producing incorrect runtime result with boxed ValueOptions #13495
You cannot compare value-options directly due to #13370
Boxing them causes the LINQ compiles but does incorrect runtime result:
Repro steps, actual behaviour
letdatasource1=[1;2].AsQueryable()// primary keyletdatasource2=[ValueSome 1; ValueSome 2].AsQueryable()//foreign key
query {for d1 in datasource1 dofor d2 in datasource2 do
where (box(ValueSome(d1))= box(d2))
select (d1, d2)}|> Seq.toList;;// val it: (int * int voption) list = []// Empty???
The same issue can be observed with Some:
letdatasource1=[1;2].AsQueryable()// primary keyletdatasource2=[ValueSome 1; ValueSome 2].AsQueryable()//foreign key
query {for d1 in datasource1 dofor d2 in datasource2 do
where (Some(ValueSome(d1))= Some(d2))
select (d1, d2)}|> Seq.toList;;// val it: (int * int voption) list = []// Empty???
Expected behavior
If I change the = to Equals, then it produces a different result:
openSystem.Linqletdatasource1=[1;2].AsQueryable()// primary keyletdatasource2=[ValueSome 1; ValueSome 2].AsQueryable()//foreign key
query {for d1 in datasource1 dofor d2 in datasource2 do
where (ValueSome(d1).Equals(d2))
select (d1, d2)}|> Seq.toList;;// val it: (int * int voption) list = [(1, ValueSome 1); (2, ValueSome 2)]
Or with boxed:
openSystem.Linqletdatasource1=[1;2].AsQueryable()// primary keyletdatasource2=[ValueSome 1; ValueSome 2].AsQueryable()//foreign key
query {for d1 in datasource1 dofor d2 in datasource2 do
where (box(ValueSome(d1)).Equals(box(d2)))
select (d1, d2)}|> Seq.toList;;
I expect this will do a method-call instead of Expression.Equals in the LINQ-tree.
Which may cause the sub-expressions not visited by LINQ for any kind of transpilation, and that's why this is not a workaround.
Is there maybe something wrong with StructuralComparison when using Linq?
Activity
Happypig375 commentedon Jul 12, 2022
I think this is fixed by #11681
dsyme commentedon Sep 21, 2022
This is indeed fixed by #11681