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.Equals and/or == fails #1130

Closed
ewoutkramer opened this issue Sep 27, 2019 · 0 comments
Closed

Expression.Equals and/or == fails #1130

ewoutkramer opened this issue Sep 27, 2019 · 0 comments
Assignees
Labels

Comments

@ewoutkramer
Copy link
Member

The code for Equals in Expression (FhirPath in common) looks like this:

   public override bool Equals(object obj) => Equals(obj as Expression);
        public bool Equals(Expression other) => other != null && EqualityComparer<TypeSpecifier>.Default.Equals(ExpressionType, other.ExpressionType);
        public override int GetHashCode() => -28965461 + EqualityComparer<TypeSpecifier>.Default.GetHashCode(ExpressionType);
        public static bool operator ==(Expression left, Expression right) => EqualityComparer<Expression>.Default.Equals(left, right);
        public static bool operator !=(Expression left, Expression right) => !(left == right);

However, when we test a subclass of Expression on equality like so:

    Expression x = new SomeSubClassExpression1();
    Expression y = new SomeSubClassExpression2();
    x == y;

this always return true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants