Elements in my `Set` are not unique

The documentation for Set says:

Elements in a Set are unique, as determined by the elements’ definition of isequal.

This doesn’t seem to be true:

struct S
    x::Vector{Int}
    S() = new(Int[])
end
Base.isequal(::S, ::S) = true
@assert isequal(S(), S())
@assert Set([S()]) == Set([S(), S()]) # error
@assert length(Set([S()])) == length(Set([S(), S()])) # error

Am I missing something?

You have to also define Base.hash.

1 Like

Got it. Thanks.