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

Incorrect ambiguity warning #8045

Closed
timholy opened this issue Aug 18, 2014 · 3 comments
Closed

Incorrect ambiguity warning #8045

timholy opened this issue Aug 18, 2014 · 3 comments
Assignees

Comments

@timholy
Copy link
Member

timholy commented Aug 18, 2014

Perhaps I'm being blind, but I can't see any way in which these two methods are ambiguous:

julia> using FixedPointNumbers

julia> scaleinfo{T}(::Type{T}, img::AbstractArray{T}) = 1
scaleinfo (generic function with 1 method)

julia> scaleinfo{To<:Ufixed,From<:FloatingPoint}(::Type{To}, img::AbstractArray{From}) = 2
Warning: New definition 
    scaleinfo(Type{To<:Ufixed},AbstractArray{From<:FloatingPoint,N}) at none:1
is ambiguous with: 
    scaleinfo(Type{T},AbstractArray{T,N}) at none:1.
To fix, define 
    scaleinfo(Type{_<:Ufixed},AbstractArray{_<:FloatingPoint,N})
before the new definition.
scaleinfo (generic function with 2 methods)

julia> isa(Ufixed8, FloatingPoint)
false

This is on 0.3-rc4. I wonder if it's related in any way to #6383.

@timholy
Copy link
Member Author

timholy commented Aug 18, 2014

Also worth pointing out:

julia> typeintersect(Ufixed, FloatingPoint)
None

@JeffBezanson JeffBezanson self-assigned this Aug 19, 2014
@timholy
Copy link
Member Author

timholy commented Aug 21, 2014

More examples:

julia> using Color, FixedPointNumbers

julia> import Color.Fractional

julia> import Base.convert

julia> convert{T<:Fractional, N, CV<:ColorValue}(::Type{Array{T,N}}, A::Array{CV,N}) = throw(DimensionMismatch())
Warning: New definition 
    convert(Type{Array{T<:Union(FixedPoint,FloatingPoint),N}},Array{CV<:ColorValue{T},N}) at none:1
is ambiguous with: 
    convert(Type{Array{T,n}},Array{T,n}) at array.jl:218.
To fix, define 
    convert(Type{Array{_<:Union(FixedPoint,FloatingPoint),N}},Array{_<:ColorValue{T},N})
before the new definition.
convert (generic function with 583 methods)

julia> convert{T<:Fractional, N, CV<:ColorValue}(::Type{Array{T}}, A::Array{CV,N}) = myconvert(Array{T}, A)
Warning: New definition 
    convert(Type{Array{T<:Union(FixedPoint,FloatingPoint),N}},Array{CV<:ColorValue{T},N}) at none:1
is ambiguous with: 
    convert(Type{Array{T,N}},Array{T,n}) at array.jl:217.
To fix, define 
    convert(Type{Array{_<:Union(FixedPoint,FloatingPoint),N}},Array{_<:ColorValue{T},N})
before the new definition.
convert (generic function with 583 methods)

I just spent a fair bit of time trying to figure out whether there is some sequence of method definitions that avoids these warnings, to no avail. Currently my only option seems to be to call it something different from convert.

@timholy
Copy link
Member Author

timholy commented May 22, 2015

Closed by #11194

@timholy timholy closed this as completed May 22, 2015
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

2 participants