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

Missing hash methods (or bad == methods) #1594

Open
thofma opened this issue Sep 4, 2024 · 4 comments
Open

Missing hash methods (or bad == methods) #1594

thofma opened this issue Sep 4, 2024 · 4 comments

Comments

@thofma
Copy link
Owner

thofma commented Sep 4, 2024

Before I forget. Here are the types with missing hash methods (or for which == should be removed). (Courtesy of @lgoettgens (oscar-system/Oscar.jl#2222). Needs julia version 1.10.5:

mod = Hecke
list = map(
  filter(names(mod; all=true)) do name
    isdefined(mod, name) || return false            # remove all wrong exports (see #1964)
    T = getfield(mod, name)
    T isa DataType || T isa UnionAll || return false  # remove all non-types and non-parametric-types
    parentmodule(==, (T, T)) == Base && return false  # remove everything without custom ==
    loc = functionloc(==, (T, T))
    endswith(loc[1], "julia/base/Base.jl") && loc[2] == 207 && return false  # remove everything without custom ==
    T <: AbstractArray && endswith(loc[1], "julia/base/abstractarray.jl") && loc[2] == 3028 && return false  # remove AbstractArray subtypes as Base provides both == and hash for them
    parentmodule(hash, (T, UInt)) == Base             # keep iff there is no custom hash
  end,
) do name
  T = getfield(mod, name)
  loc = functionloc(==, (T, T))
  if occursin("mod.jl/", loc[1])
    loc_cleaned = loc[1][first(findlast("mod.jl/", loc[1])):end]
  elseif occursin("packages/", loc[1])
    loc_cleaned = loc[1][(first(findlast("packages/", loc[1])) + length("packages/")):end]
  elseif occursin("julia/base/", loc[1])
    loc_cleaned = loc[1][first(findlast("julia/base/", loc[1])):end]
  else
    loc_cleaned = loc[1]
  end
  name, parentmodule(T), (loc_cleaned, loc[2])
end;

This yields

27-element Vector{Tuple{Symbol, Module, Tuple{String, Int32}}}:
 (:AbsAlgAssIdl, Hecke, ("/Users/thofma/software/Hecke.jl/src/AlgAss/Ideal.jl", 294))
 (:AbsNumFieldOrderFractionalIdealSet, Hecke, ("/Users/thofma/software/Hecke.jl/src/NumFieldOrd/NfOrd/FracIdeal.jl", 169))
 (:AbsNumFieldOrderIdealSet, Hecke, ("/Users/thofma/software/Hecke.jl/src/NumFieldOrd/NfOrd/Ideal/Ideal.jl", 69))
 (:AcbFieldElem, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/acb.jl", 332))
 (:AlgAssAbsOrd, Hecke, ("/Users/thofma/software/Hecke.jl/src/AlgAssAbsOrd/Order.jl", 547))
 (:AlgAssAbsOrdIdlSet, Hecke, ("/Users/thofma/software/Hecke.jl/src/AlgAssAbsOrd/Ideal.jl", 1492))
 (:AlgAssRelOrd, Hecke, ("/Users/thofma/software/Hecke.jl/src/AlgAssRelOrd/Order.jl", 371))
 (:ArbFieldElem, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/arb.jl", 355))
 (:CMType, Hecke, ("/Users/thofma/software/Hecke.jl/src/NumField/CM.jl", 60))
 (:ClassField, Hecke, ("/Users/thofma/software/Hecke.jl/src/RCF/class_fields.jl", 240))
 (:ComplexFieldElem, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/Complex.jl", 321))
 (:FinGenAbGroupHom, Hecke, ("/Users/thofma/software/Hecke.jl/src/GrpAb/Map.jl", 217))
 (:GenOrdFracIdl, Hecke, ("/Users/thofma/software/Hecke.jl/src/GenOrd/FractionalIdeal.jl", 272))
 (:LocElem, AbstractAlgebra.Generic, ("AbstractAlgebra/AqzuZ/src/NCRings.jl", 86))
 (:LocalQuadSpaceCls, Hecke, ("/Users/thofma/software/Hecke.jl/src/QuadForm/Quad/Spaces.jl", 2144))
 (:LocalizedEuclideanRingElem, AbstractAlgebra.Generic, ("AbstractAlgebra/AqzuZ/src/NCRings.jl", 86))
 (:MapParent, Hecke, ("/Users/thofma/software/Hecke.jl/src/GrpAb/Map.jl", 506))
 (:OrdLocElem, Hecke, ("AbstractAlgebra/AqzuZ/src/NCRings.jl", 86))
 (:QuadSpaceCls, Hecke, ("/Users/thofma/software/Hecke.jl/src/QuadForm/Quad/Spaces.jl", 2340))
 (:RCFCharacter, Hecke, ("/Users/thofma/software/Hecke.jl/src/RCF/rcf_stark.jl", 23))
 (:RealFieldElem, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/Real.jl", 339))
 (:RealNumberFieldElem, Hecke, ("/Users/thofma/software/Hecke.jl/src/Misc/RealNumberField.jl", 92))
 (:RelFinFieldElem, Hecke, ("AbstractAlgebra/AqzuZ/src/NCRings.jl", 86))
 (:RelNumFieldOrder, Hecke, ("/Users/thofma/software/Hecke.jl/src/NumFieldOrd/NfRelOrd/NfRelOrd.jl", 620))
 (:acb, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/acb.jl", 332))
 (:arb, Nemo, ("/Users/thofma/.julia/dev/Nemo/src/arb/arb.jl", 355))
 (:nf_elem_mod, Hecke, ("AbstractAlgebra/AqzuZ/src/NCRings.jl", 86))
@lgoettgens
Copy link
Contributor

The above code is dependent on a specific julia version. E.g. for julia 1.10.5, you need to replace loc[2] == 127 by loc[2] == 165.

@thofma
Copy link
Owner Author

thofma commented Sep 6, 2024

Thanks

@lgoettgens
Copy link
Contributor

Just FYI, I updated the script in oscar-system/Oscar.jl#2222 (comment) to work on julia 1.11.1, and it now filters out some few false positives

@thofma
Copy link
Owner Author

thofma commented Nov 29, 2024

updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants