Skip to content

ValueOption equality on expression trees causes crash #13370

@Thorium

Description

@Thorium

I'm trying to have an expression tree to compare a struct with the same item, and it fails?

open System
open System.Linq.Expressions
//let tester = Some "a" //works
//let tester = Guid.NewGuid() //works
let tester = ValueSome "b" //crash

let equalExpr = Expression.Equal(Expression.Constant(tester), Expression.Constant(tester))

//System.InvalidOperationException: The binary operator Equal is not defined for the types 
// 'Microsoft.FSharp.Core.FSharpValueOption`1[System.String]' and 
// 'Microsoft.FSharp.Core.FSharpValueOption`1[System.String]'.
//   at System.Linq.Expressions.Expression.GetEqualityComparisonOperator(ExpressionType binaryType, String opName, Expression left, Expression right, Boolean liftToNull)
//   at System.Linq.Expressions.Expression.Equal(Expression left, Expression right, Boolean liftToNull, MethodInfo method)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-QueriesQuery expressions and library implementationBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions