Skip to content

hash malfunction for x::UnionAll #52371

@goulf-3m

Description

@goulf-3m

For Set, unique to work, correct hashing is required.
Before isequal is used for comparison, hash is used to find the slot.
Thus, equal values should have equal hashes, so as to meet at the same slot.

However, for UnionAll types, hash is unstable: equal values have different hashes:

julia> a=Array{T} where T
Array
julia> b=Array{T2} where T2
Array
julia> a==b, a===b, hash(a), hash(b)
(true, false, 0x3e735c1c362de00f, 0x6ba6f097cee26fae)
julia> unique([a,b])
2-element Vector{UnionAll}:
 Array
 Array

versioninfo():

Julia Version 1.9.4
Commit 8e5136fa297 (2023-11-14 08:46 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 9 6900HX with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 16 virtual cores

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions