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(, ::Dict) error in Pkg.build #15789

Closed
yuyichao opened this issue Apr 7, 2016 · 6 comments · Fixed by #15802
Closed

map(, ::Dict) error in Pkg.build #15789

yuyichao opened this issue Apr 7, 2016 · 6 comments · Fixed by #15802
Labels
packages Package management and loading regression Regression in behavior compared to a previous version

Comments

@yuyichao
Copy link
Contributor

yuyichao commented Apr 7, 2016

This is kind of the opposite problem with #15342. On latest master, the following code that is slightly modified from Pkg.Entry.build(::Vector) throws an error since it want to construct a Dict. This causes the useless error message when the build process failed in https://ci.appveyor.com/project/StevenGJohnson/ijulia-jl/build/1.0.46/job/smsrhgui56r3w006

julia> errs = Dict()
Dict{Any,Any}()

julia> errs["1"] = "2"
"2"

julia> map(x->x[1], errs)
ERROR: MethodError: no method matching similar(::Dict{Any,Any}, ::Type{ASCIIString})
Closest candidates are:
  similar(::SubArray{T,N,P,I,L}, ::Any, ::Tuple{Vararg{Int64}})
  similar{T}(::Array{T,1}, ::Any)
  similar{T}(::Array{T,2}, ::Any)
  ...
 in _collect(::Dict{Any,Any}, ::Base.Generator{Dict{Any,Any},##1#2}, ::Base.EltypeUnknown, ::Base.HasLength) at ./array.jl:249
 [inlined code] from ./array.jl:224
 in map(::Any, ::Dict{Any,Any}) at ./abstractarray.jl:1168
 in eval(::Module, ::Any) at ./boot.jl:237

I opened this issue since I'm not sure which one should be fixed (the use or map).

@JeffBezanson
Copy link
Member

It looks like this use case wants simply keys(dict).

@JeffBezanson JeffBezanson added packages Package management and loading regression Regression in behavior compared to a previous version labels Apr 7, 2016
@yuyichao
Copy link
Contributor Author

yuyichao commented Apr 7, 2016

That's true. This case can easily be fixed. I'm more wondering about e.g. map(x->x[1]*x[2], Dict("1"=>"2")) and other subtle breakage caused by this change.

@JeffBezanson
Copy link
Member

I think something that's expecting to construct an array derived from a Dict should not use map.

@yuyichao
Copy link
Contributor Author

yuyichao commented Apr 7, 2016

What to use instead? Comprehension?

@JeffBezanson
Copy link
Member

Yes, a comprehension would be good. I'm not sure how usual it is to even define map on a Dict, but if it exists many would expect it to return another Dict.

yuyichao added a commit that referenced this issue Apr 8, 2016
Also fix `pkg` test on non-en locale.

Fixes #15789
@nalimilan
Copy link
Member

Yes, a comprehension would be good. I'm not sure how usual it is to even define map on a Dict, but if it exists many would expect it to return another Dict.

This is #5794.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
packages Package management and loading regression Regression in behavior compared to a previous version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants