JuliaCollections / JuliaCollections/DataStructures.jl
DefaultDict accessor fails when the default is not the value type
Open
Nobody has claimed this yet.
documentation
- Dominant language
- Julia
- Stars
- 745
- Forks
- 261
- PR merge metrics
- No merged PRs in 30d
Description
MWE:
pkg> st DataStructures
[864edb3b] DataStructures v0.18.18
julia> using DataStructures
julia> dd = DefaultDict(1, :a => (2,))
DefaultDict{Symbol, Tuple{Int64}, Int64} with 1 entry:
:a => (2,)
julia> dd[:b]
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Tuple{Int64}
Closest candidates are:
convert(::Type{T}, ::T) where T<:Tuple
@ Base essentials.jl:451
convert(::Type{T}, ::T) where T
@ Base Base.jl:84
convert(::Type{T}, ::CartesianIndex) where T<:Tuple
@ Base multidimensional.jl:136
...
Stacktrace:
[1] get!
@ Base ./dict.jl:481 [inlined]
[2] get!
@ Base ./abstractdict.jl:552 [inlined]
[3] getindex
@ DataStructures ~/.julia/packages/DataStructures/jFDPC/src/default_dict.jl:63 [inlined]
[4] getindex(a::DefaultDict{Symbol, Tuple{Int64}, Int64}, args::Symbol)
@ DataStructures ~/.julia/packages/DataStructures/jFDPC/src/delegate.jl:21
[5] top-level scope
@ REPL[111]:1
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the MWE in the Julia REPL, then inspect src/default_dict.jl at the getindex location and the delegation in src/delegate.jl. Trace how the default is passed to get!, determine the intended behavior for mismatched default and value types, and verify the reported MethodError is resolved with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100