Skip to content

hashing of array of arrays with length > 3 #27865

Closed
@SimonDanisch

Description

@SimonDanisch
julia> hash([["asd"], ["asd"], ["asad"]])
ERROR: MethodError: no method matching -(::String, ::String)
Stacktrace:
 [1] _broadcast_getindex_evalf at .\broadcast.jl:585 [inlined]
 [2] _broadcast_getindex at .\broadcast.jl:558 [inlined]
 [3] getindex at .\broadcast.jl:518 [inlined]
 [4] copy at .\broadcast.jl:769 [inlined]
 [5] materialize at .\broadcast.jl:735 [inlined]
 [6] broadcast(::typeof(-), ::Array{String,1}, ::Array{String,1}) at .\broadcast.jl:713
 [7] - at .\arraymath.jl:39 [inlined]
 [8] hash(::Array{Array{String,1},1}, ::UInt64) at .\abstractarray.jl:2104
 [9] hash(::Array{Array{String,1},1}) at .\hashing.jl:18
 [10] top-level scope at none:0

Another version fails at the broadcast check, but I think that's just the same problem with a different shape.
Problem seems to be the isapplicable(-, x1, x2) branch in https://github.com/JuliaLang/julia/blob/master/base/abstractarray.jl#L2107.
Since there is -(x::AbstractArray, y::AbstractArray) in https://github.com/JuliaLang/julia/blob/master/base/arraymath.jl#L36, that becomes true, even though the elements (strings) of the array don't support -.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behaviorhashing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions