Skip to content

Comparisons with nullable types #380

Closed

Description

@celi

Hi,

It looks like FastExpressionCompiler is not comparing correctly nullable types. I didn't find any mention of it.

public static class FastExpressionCompilerTests
{
    public class Test
    {
        public decimal? D1 { get; set; }
    }

    public static void RunTest()
    {
        Expression<Func<Test, bool>> expression = t => t.D1 < 20;

        var normalCompiled = expression.Compile();

        var fastCompiled = expression.CompileFast(true, CompilerFlags.EnableDelegateDebugInfo);

        var test = new Test()
        {
            D1 = null
        };

        var result1 = normalCompiled(test); // false

        var result2 = fastCompiled(test); // true
    }
}

after execution result1 is equal false, but result2 is equal true

Activity

  1. changed the title [-]Comparisons with nullable values[/-] [+]Comparisons with nullable types[/+] on Dec 5, 2023
  2. self-assigned this
    on Jan 15, 2024
  3. added this to the v4.0.2 milestone on Jan 15, 2024
  4. dadhi commented on Jan 15, 2024

    @dadhi
    Owner

    @celi Missed this one, will look now. Thanks for posting.

  5. dadhi commented on Jan 19, 2024

    @dadhi
    Owner

    @celi Yep, reproduced :/ Will fix.

  6. added a commit that references this issue on Jan 20, 2024
  7. added a commit that references this issue on Jan 31, 2024
    9290946
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions