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

OrderedDict iteration does not hit deprecation #27247

Closed
mauro3 opened this issue May 24, 2018 · 2 comments
Closed

OrderedDict iteration does not hit deprecation #27247

mauro3 opened this issue May 24, 2018 · 2 comments

Comments

@mauro3
Copy link
Contributor

mauro3 commented May 24, 2018

My impression was that the old iteration interface should keep on working but throw deprecation warnings. However for OrderedDict this fails:

julia> using DataStructures                                                                                                                                              
                                                                                                                                                                         
julia> od = OrderedDict(:a=>5);                                                                                                                                          
                                                                                                                                                                         
julia> for o in od; end                                                                                                                                                  
ERROR: MethodError: no method matching done(::Array{Symbol,1}, ::Int64)                                                                                                  
Closest candidates are:
  done(::DataStructures.TrieIterator, ::Any) at /home/mauro/.julia/packages/DataStructures/hWrs/src/trie.jl:122
  done(::DataStructures.IntSet, ::Any) at /home/mauro/.julia/packages/DataStructures/hWrs/src/int_set.jl:191
  done(::DataStructures.EnumerateAll, ::Any) at /home/mauro/.julia/packages/DataStructures/hWrs/src/multi_dict.jl:114
  ...                                                                                                                                                                    
Stacktrace:                                                                                                                                                              
 [1] done(::OrderedDict{Symbol,Int64}, ::Int64) at /home/mauro/.julia/packages/DataStructures/hWrs/src/ordered_dict.jl:429                                               
 [2] iterate at ./essentials.jl:824 [inlined]                                                                                                                            
 [3] iterate(::OrderedDict{Symbol,Int64}) at ./essentials.jl:828                                                                                                         
 [4] top-level scope at ./<missing>:0                                                                                                                                    

due to it calling into the done of Vector: https://github.com/JuliaCollections/DataStructures.jl/blob/a0a289cb158516ef34cda7a123ac87c901da0e87/src/ordered_dict.jl#L429

I don't know whether there is anything which can be done about this.

Cc @Keno

(PS: there is no NEWS entry for the new iteration protocol)

@Keno
Copy link
Member

Keno commented May 24, 2018

The deprecation is best effort and only works if the iteration protocol is followed. In this case it is not, because the start function on OrderedDict returns a 1, not a start(::Vector). In any case, I would advise just moving to the new iteration protocol as quickly as possible.

@mauro3
Copy link
Contributor Author

mauro3 commented May 24, 2018

Ok, I'll close and report overthere.

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