Struct SIMD - Missing trait 'EqualityComparable'?

Any reason struct SIMD is missing the EqualityComparable trait? It appears to have the methods implemented.
As shown below, I’m seeing the error: argument type 'SIMD[uint64, 1]' does not conform to trait 'EqualityComparable & Copyable & Movable'
Mojo 25.4.0.dev2025060805

foos = List[UInt64]()
some_foo = 12345

# failed to infer parameter #2, argument type 'SIMD[uint64, 1]' does not conform to trait 'EqualityComparable & Copyable & Movable'
if some_foo in foos: # <-- Error here
    pass

struct SIMD[dtype: DType, size: Int](
    Absable,
    Boolable,
    Ceilable,
    CeilDivable,
    Copyable,
    Movable,
    DevicePassable,
    ExplicitlyCopyable,
    Floatable,
    Floorable,
    Hashable,
    _HashableWithHasher,
    Indexer,
    PythonConvertible,
    Representable,
    Roundable,
    Sized,
    Stringable,
    Writable,
):
    ...

EqualityComparable means returning single boolean. But comparison with vector means returning vector of boolean.

[1, 2, 3, 4] == [1, 2, 5, 6]  # [True,True,False,False]

So you can’t return single boolean for vector. As for scalar case It will be added after the requires clause is added.

Using DType.uint64 as shown below emits an error on assignment, cannot implicitly convert 'DType' value to 'Copyable & Movable' in type parameter.

fn main():
    # cannot implicitly convert 'DType' value to 'Copyable & Movable' in type parameter
    foos = List[DType.uint64]()  # <-- Error here
    some_foo = 12345

    if some_foo in foos:
        pass

struct DType(
    Copyable,
    Movable,
    EqualityComparable,
    ExplicitlyCopyable,
    Hashable,
    Representable,
    Stringable,
    Writable,
    _HashableWithHasher,
):
    ...

Also there is a thread below too.Why Float is Not Comparable

1 Like

Yep, my 2c is that we need to fix this. SIMD not conforming to equatable and comparable will break pretty much all generic algorithms from working with floating point and sized integer types, and will prevent merging Int and UInt into SIMD someday.

3 Likes

Agreed. This is one of the team’s priorities for Q3.

6 Likes