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

Define a method for hash(::Type, ::UInt) #49636

Merged
merged 1 commit into from
May 6, 2023
Merged

Define a method for hash(::Type, ::UInt) #49636

merged 1 commit into from
May 6, 2023

Commits on May 5, 2023

  1. Define a method for hash(::Type, ::UInt)

    Currently, `hash(::Type, ::UInt)` uses `objectid`, which can have some
    odd behavior for types: in particular, subsequent identical type-valued
    variable definitions can have `objectid`s which differ from the first
    such definition. This has some bizarre downstream effects when e.g.
    using types as the values of a `Set` or the keys of a `Dict`. See issue
    49620 for examples.
    
    There is an internal `type_hash` C function used for caching types but
    isn't exposed to Julia, as Jameson pointed out in the linked issue. This
    commit exposes it as `jl_type_hash` which is then used via `ccall` to
    define a method `hash(::Type, ::UInt)`. This method then fixes #49620.
    Note, however, that this does not affect the differing `objectid`s for
    otherwise identical types.
    ararslan committed May 5, 2023
    Configuration menu
    Copy the full SHA
    9249904 View commit details
    Browse the repository at this point in the history