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

undetected method ambiguity #12814

Closed
SimonDanisch opened this issue Aug 26, 2015 · 3 comments
Closed

undetected method ambiguity #12814

SimonDanisch opened this issue Aug 26, 2015 · 3 comments
Labels
types and dispatch Types, subtyping and method dispatch

Comments

@SimonDanisch
Copy link
Contributor

I ran into the following:

abstract FSV{N, T}
#works as expected when moved here
#Base.call{T <: FSV, X <: Array}(::Type{T}, x::X) = "excellent"
immutable Vec{N, T} <: FSV{N, T}
    x::NTuple{N, T}
end
Base.call{T <: FSV, X <: Array}(::Type{T}, x::X) = "excellent"

julia> Vec([1,2,3])
"excellent"
julia> Vec{3, Float32}([1,2,3])
ERROR: MethodError: `convert` has no method matching convert(::Type{Tuple{Float32,Float32,Float32}}, ::Array{Int64,1})
julia> versioninfo()                                                                                     
Julia Version 0.4.0-dev+6945                                                                             
Commit 90346c1 (2015-08-24 19:21 UTC)                                                                    
Platform Info:                                                                                           
  System: Windows (x86_64-w64-mingw32)                                                                   
  CPU: Intel(R) Core(TM) i3-4130 CPU @ 3.40GHz                                                           
  WORD_SIZE: 64                                                                                          
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)                                       
  LAPACK: libopenblas                                                                                    
  LIBM: libopenlibm                                                                                      
  LLVM: libLLVM-3.3                                                                                                                                                                                           

@yuyichao comments: probably not #265 but similar

@vtjnash
Copy link
Member

vtjnash commented Aug 26, 2015

it's not # 265, it's an undetected method ambiguity. here's the signature of the method that matched:
call{N,T}(::Type{Test1.Vec{N,T}}, x) at none:5
vs. the one you were hoping to match:
call{T <: FSV, X <: Array}(::Type{T}, x::X)

@vtjnash vtjnash changed the title Method caching problem undetected method ambiguity Aug 26, 2015
@JeffBezanson JeffBezanson added the types and dispatch Types, subtyping and method dispatch label Aug 26, 2015
SimonDanisch added a commit to SimonDanisch/FixedSizeArrays.jl that referenced this issue Sep 1, 2015
@SimonDanisch
Copy link
Contributor Author

This seems very similar on the newest rc2:

immutable Style{T} end

test{T <: Union{AbstractFloat, Array}}(::Array{T,3}, ::Style{:iso}) = "iso"
test{T <: Union{AbstractFloat, Array}}(::Array{T,3}, ::Style) = "default"
test(rand(Float32, 3,3,3), Style{:x}()) #both call default
test(rand(Float32, 3,3,3), Style{:iso}())

Changing declaration order also makes it work "correctly"

@JeffBezanson
Copy link
Member

Seems to be fixed after #18457.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types and dispatch Types, subtyping and method dispatch
Projects
None yet
Development

No branches or pull requests

3 participants