Skip to content

reflect_partial_cmp is not transitive and disagrees with reflect_partial_eq #22586

@SkiFire13

Description

@SkiFire13

Bevy version and features

What you did

I tried the following code:

use bevy_reflect::{PartialReflect, Reflect};

#[derive(Reflect)]
enum A {
    Foo,
    Bar,
}

#[derive(Reflect)]
enum B {
    Bar,
    Foo,
}

fn main() {
    dbg!(A::Foo.reflect_partial_cmp(&A::Bar)); // Some(Less)
    dbg!(A::Bar.reflect_partial_cmp(&B::Foo)); // Some(Equal)
    dbg!(A::Foo.reflect_partial_cmp(&B::Foo)); // Some(Equal)

    dbg!(A::Bar.reflect_partial_cmp(&B::Foo)); // Some(Equal)
    dbg!(A::Bar.reflect_partial_eq(&B::Foo)); // Some(false)
}

What went wrong

In the first 3 checks we can notice that A::Foo < A::Bar = B::Foo. From this we should conclude that A::Foo < B::Foo, however we also get A::Foo = Bar::Foo.

In the last 2 checks we can notice that A::Bar = B::Foo when compared using reflect_partial_cmp, however A::Bar != B::Foo when compared using reflect_partial_eq

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ReflectionRuntime information about typesC-BugAn unexpected or incorrect behaviorD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions