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

Method ordering error #14935

Closed
kmsquire opened this issue Feb 4, 2016 · 5 comments
Closed

Method ordering error #14935

kmsquire opened this issue Feb 4, 2016 · 5 comments

Comments

@kmsquire
Copy link
Member

kmsquire commented Feb 4, 2016

Noted here:

julia> Pkg.test("GZip")
INFO: Testing GZip
WARNING: New definition
    write(GZip.GZipStream, Array{#T<:Any, N<:Any}) at /Users/kmsquire/.julia/v0.5/GZip/src/GZip.jl:456
is ambiguous with:
    write(Base.IO, Array{UInt8, N<:Any}) at io.jl:154.
To fix, define
    write(GZip.GZipStream, Array{UInt8, N<:Any})
before the new definition.

This seems like an bug. GZipStream is a concrete subclass of IO, so shouldn't the definition involving it take precedence?

julia> versioninfo()
Julia Version 0.5.0-dev+2440
Commit 2bb94d6 (2016-02-01 02:22 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.4.0)
  CPU: Intel(R) Core(TM)2 Extreme CPU X7900  @ 2.80GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Core2)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1
@kmsquire kmsquire changed the title Dispatch error Method ordering error Feb 4, 2016
@yuyichao
Copy link
Contributor

yuyichao commented Feb 4, 2016

Why is this a bug? The first method only works with GZipStream and the second method only works with Array{UInt8} so they are indeed ambiguous?

@yuyichao
Copy link
Contributor

yuyichao commented Feb 4, 2016

In another word, write(::GZip.GZipStream, ::Vector{Int}) only matches the first one and write(::IOBuffer, ::Vector{UInt8}) only matches the second one so none of them are more specific than the other so they are ambiguous.

I remember there's some discussion about sorting the method using the first argument first but I don't think we have that yet.

@kmsquire
Copy link
Member Author

kmsquire commented Feb 4, 2016

Hmm.. Okay.

I see that this was caused by #14766, so GZip.jl will have to be updated to deal with that then.

@carnaval
Copy link
Contributor

carnaval commented Feb 4, 2016

I remember there's some discussion about sorting the method using the first argument first but I don't think we have that yet.

as an aside, please no. the fact that our multiple dispatch is symmetric is to me what makes it elegant

@kmsquire
Copy link
Member Author

kmsquire commented Feb 4, 2016

No worries--I think it was just my misunderstanding. Cheers!

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

3 participants