-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
help wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull requestneeds testsUnit tests are required for this changeUnit tests are required for this changetypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch
Milestone
Description
came across this while investigating why the inference of isassigned is bad. it seems the sub2ind definitions cause several problems for type intersection. for example:
julia> @which sub2ind((1,))
ERROR: no method found for the specified argument types
in which(::Any, ::Any) at ./reflection.jl:466
julia> sub2ind((1,)) # supposed to throw a MethodError (ambiguity)
1this is caused by the intersection of the following 3 methods:
sub2ind{N,T<:Integer}(inds:: Union{Base.Indices{N}, Dims{N}}, I::AbstractArray{T,1}...) at abstractarray.jl:1482
sub2ind(::Base.DimsInteger) at abstractarray.jl:1429
sub2ind(dims::Base.DimsInteger, I::Integer...) at abstractarray.jl:1433testing with:
julia> g{N,T<:Integer}(inds::Dims{N}, I::AbstractArray{T,1}...) = 1
julia> g(::Base.DimsInteger) = 2
julia> g(dims::Base.DimsInteger, I::Integer...) = 3with all 3, @which thinks none will be called, but actually 2 gets (incorrectly) called
with just method 1 and 2, @which thinks that 1 will definitely be called (but 2 is actually – correctly – called)
with just 1 and 3, it fails correctly
with just 2 and 3, it works correctly
Metadata
Metadata
Assignees
Labels
help wantedIndicates that a maintainer wants help on an issue or pull requestIndicates that a maintainer wants help on an issue or pull requestneeds testsUnit tests are required for this changeUnit tests are required for this changetypes and dispatchTypes, subtyping and method dispatchTypes, subtyping and method dispatch