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

Heterogeneous multi dict #222

Open
jw3126 opened this issue Oct 30, 2016 · 5 comments
Open

Heterogeneous multi dict #222

jw3126 opened this issue Oct 30, 2016 · 5 comments

Comments

@jw3126
Copy link

jw3126 commented Oct 30, 2016

I can do

Dict(1 => 1, 2=> "two")

but

using DataStructures
MultiDict(1 => 1, 2 => "two")

throws an error:

LoadError: MethodError: no method matching DataStructures.MultiDict{K,V}(::Pair{Int64,Int64}, ::Pair{Int64,String})
Closest candidates are:
  DataStructures.MultiDict{K,V}{K,V}(!Matched::Pair{K,V}...) at /home/jan/.julia/v0.6/DataStructures/src/multi_dict.jl:36
  DataStructures.MultiDict{K,V}(::Any) at /home/jan/.julia/v0.6/DataStructures/src/multi_dict.jl:20
  DataStructures.MultiDict{K,V}{T}(::Any) at sysimg.jl:66
while loading In[27], in expression starting on line 2

is this expected?

@kmsquire
Copy link
Member

Certainly not desired. https://github.com/JuliaLang/DataStructures.jl/blob/52615e84024f2ac666469fb8f2af95a6194ad84c/src/multi_dict.jl is almost certainly missing a relevant constructor. Pull requests welcome!

@jw3126
Copy link
Author

jw3126 commented Oct 31, 2016

Yeah I tried to fix it, but so far I keep hitting JuliaLang/julia#19159.

@kmsquire
Copy link
Member

@wildart I originally thought this issue was related to SortedMultiDicts, because I forgot that you had contributed a MultiDict implementation. Since there are no docs for MultiDict, it's hard to know what the expected behavior or solution is here. Would you be able to add some documentation under doc/source/?

@bjarthur
Copy link

same problem for SortedDict:

julia> SortedDict(1 => 1, 2 => "two")
ERROR: MethodError: no method matching DataStructures.SortedDict{K,D,Ord<:Base.Order.Ordering}(::Pair{Int64,Int64}, ::Pair{Int64,String})
Closest candidates are:
  DataStructures.SortedDict{K,D,Ord<:Base.Order.Ordering}{K,D}(::Pair{K,D}...) at /Users/arthurb/.julia/v0.5/DataStructures/src/sorted_dict.jl:35
  DataStructures.SortedDict{K,D,Ord<:Base.Order.Ordering}{K,D,Ord<:Base.Order.Ordering}(::Ord<:Base.Order.Ordering, ::Pair{K,D}...) at /Users/arthurb/.julia/v0.5/DataStructures/src/sorted_dict.jl:48
  DataStructures.SortedDict{K,D,Ord<:Base.Order.Ordering}(::Any) at /Users/arthurb/.julia/v0.5/DataStructures/src/sorted_dict.jl:57
  ...

@StephenVavasis
Copy link
Contributor

Yes, it does appear that there is a constructor missing for SortedDict (and also SortedMultiDict). As a temporary workaround, you can try

      SortedDict(Dict(1 => 1, 2 => "two"))

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

4 participants