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

map on pairs on NamedTuples doesn't work #25223

Closed
quinnj opened this issue Dec 21, 2017 · 4 comments
Closed

map on pairs on NamedTuples doesn't work #25223

quinnj opened this issue Dec 21, 2017 · 4 comments
Labels
collections Data structures holding multiple items, e.g. sets

Comments

@quinnj
Copy link
Member

quinnj commented Dec 21, 2017

julia> t = (a=1, b=2, c=3)
(a = 1, b = 2, c = 3)

julia> map(println, pairs(t))
ERROR: MethodError: Cannot `convert` an object of type Base.Generator{Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}},typeof(println)} to an object of type Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}}
This may have arisen from a call to the constructor Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}}(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}}(::Base.Generator{Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}},typeof(println)}) at ./sysimg.jl:124
 [2] map(::Function, ::Base.Iterators.IndexValue{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}}) at ./deprecated.jl:57
 [3] top-level scope
@JeffBezanson
Copy link
Member

IndexValue is an AbstractDict, so it's hitting a deprecated method designed for Dicts.

@ararslan ararslan added the collections Data structures holding multiple items, e.g. sets label Dec 21, 2017
@vtjnash
Copy link
Member

vtjnash commented Dec 21, 2017

Maybe we should un-deprecate that method? But this wouldn't work anyways, since the OP should be using foreach (which already works for both):

julia> map(println, pairs(Dict(1=>2, 2=>3)))
W- `map(f, d::T) where T <: AbstractDict` is deprecated, use `T((f(p) for p = pairs(d)))` instead. -Warn:Core:julia_internal.h:380
|  caller = jl_call_fptr_internal at julia_internal.h:380 [inlined]
2 => 3
ERROR: MethodError: no method matching start(::Nothing)
Closest candidates are:
  start(::SimpleVector) at essentials.jl:550
  start(::Base.MethodList) at reflection.jl:672
  start(::ExponentialBackOff) at error.jl:171
  ...
Stacktrace:
 [1] Dict{Int64,Int64}(::Base.Generator{Dict{Int64,Int64},typeof(println)}) at ./dict.jl:116
 [2] map(::Function, ::Dict{Int64,Int64}) at ./deprecated.jl:57
 [3] top-level scope

@KristofferC
Copy link
Member

This now gives an error that map is explicitly not implemented for this type.

@vtjnash
Copy link
Member

vtjnash commented Oct 15, 2019

dup #5794

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
collections Data structures holding multiple items, e.g. sets
Projects
None yet
Development

No branches or pull requests

5 participants