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

Fix method ambiguity in similar() #165

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

rdeits
Copy link
Contributor

@rdeits rdeits commented Feb 22, 2018

Before:

julia> using ZMQ

julia> m = Message("hello")
5-element ZMQ.Message:
 0x68
 0x65
 0x6c
 0x6c
 0x6f

julia> similar(m, UInt8, 5)
ERROR: MethodError: similar(::ZMQ.Message, ::Type{UInt8}, ::Tuple{Int64}) is ambiguous. Candidates:
  similar(a::AbstractArray, ::Type{T}, dims::Tuple{Vararg{Int64,N}}) where {T, N} in Base at abstractarray.jl:527
  similar(a::AbstractArray, ::Type{T}, dims::Union{Tuple{Base.OneTo,Vararg{Base.OneTo,N} where N}, Tuple{Integer,Vararg{Integer,N} where N}}) where T in Base at abstractarray.jl:525
  similar(a::ZMQ.Message, T, dims::Tuple{Vararg{Int64,N}} where N) in ZMQ at /Users/rdeits/.julia/v0.6/ZMQ/src/ZMQ.jl:385
Possible fix, define
  similar(::ZMQ.Message, ::Type{T}, ::Tuple{Int64,Vararg{Int64,N}})
Stacktrace:
 [1] similar(::ZMQ.Message, ::Type{UInt8}, ::Int64) at ./abstractarray.jl:524

after:

julia> m = Message("hello")
5-element ZMQ.Message:
 0x68
 0x65
 0x6c
 0x6c
 0x6f

julia> similar(m, UInt8, 5)
5-element Array{UInt8,1}:
 0xd0
 0x46
 0x1a
 0x18
 0x01

julia> copy(m)
5-element Array{UInt8,1}:
 0x68
 0x65
 0x6c
 0x6c
 0x6f

Tested with Julia v0.6.2 on OSX.

@rdeits
Copy link
Contributor Author

rdeits commented Feb 22, 2018

Sorry for the commit spam; I'm trying to figure out why Appveyor is failing and don't have a Windows machine to test on.

@rdeits
Copy link
Contributor Author

rdeits commented Feb 22, 2018

Ok, I have a workaround for the Appveyor failure (although I think it's a real issue: #166 ). The remaining Appveyor failures on nightly appear to be caused by general problems with downloading Windows nightlies: JuliaLang/julia#25926 (comment)

@rdeits
Copy link
Contributor Author

rdeits commented Apr 3, 2018

Just following up on this. Is there anyone who can spare a code review?

@stevengj stevengj merged commit 6ed45b5 into JuliaInterop:master Apr 3, 2018
@stevengj
Copy link
Contributor

stevengj commented Apr 3, 2018

LGTM.

@rdeits
Copy link
Contributor Author

rdeits commented Apr 3, 2018

Thanks!

@rdeits rdeits deleted the fix-similar branch April 3, 2018 21:20
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

Successfully merging this pull request may close these issues.

2 participants