Skip to content

Commit

Permalink
fix missing ambiguity test (JuliaLang#23055)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 14, 2017
1 parent 6aa80c3 commit ac714a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions base/linalg/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ A_mul_B!(C::AbstractMatrix, A::BiTri, B::BiTriSym) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractMatrix, A::BiTriSym, B::BiTriSym) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractMatrix, A::AbstractTriangular, B::BiTriSym) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractMatrix, A::AbstractMatrix, B::BiTriSym) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractMatrix, A::Diagonal, B::BiTriSym) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractVector, A::BiTri, B::AbstractVector) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractMatrix, A::BiTri, B::AbstractVecOrMat) = A_mul_B_td!(C, A, B)
A_mul_B!(C::AbstractVecOrMat, A::BiTri, B::AbstractVecOrMat) = A_mul_B_td!(C, A, B)
Expand Down
18 changes: 12 additions & 6 deletions base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1205,19 +1205,21 @@ function test_approx_eq_modphase(a::StridedVecOrMat{S}, b::StridedVecOrMat{T},
end

"""
detect_ambiguities(mod1, mod2...; imported=false, ambiguous_bottom=false)
detect_ambiguities(mod1, mod2...; imported=false, recursive=false, ambiguous_bottom=false)
Returns a vector of `(Method,Method)` pairs of ambiguous methods
defined in the specified modules. Use `imported=true` if you wish to
also test functions that were imported into these modules from
elsewhere.
defined in the specified modules.
Use `imported=true` if you wish to also test functions that were
imported into these modules from elsewhere.
Use `recursive=true` to test in all submodules.
`ambiguous_bottom` controls whether ambiguities triggered only by
`Union{}` type parameters are included; in most cases you probably
want to set this to `false`. See [`Base.isambiguous`](@ref).
"""
function detect_ambiguities(mods...;
imported::Bool = false,
recursive::Bool = false,
ambiguous_bottom::Bool = false,
allow_bottom::Union{Bool,Void} = nothing)
if allow_bottom !== nothing
Expand All @@ -1239,8 +1241,12 @@ function detect_ambiguities(mods...;
println("Skipping ", mod, '.', n) # typically stale exports
continue
end
f = getfield(mod, n)
if isa(f, DataType) && isdefined(f.name, :mt)
f = Base.unwrap_unionall(getfield(mod, n))
if recursive && isa(f, Module) && f !== mod && module_parent(f) === mod && module_name(f) === n
subambs = detect_ambiguities(f,
imported=imported, recursive=recursive, ambiguous_bottom=ambiguous_bottom)
union!(ambs, subambs)
elseif isa(f, DataType) && isdefined(f.name, :mt)
mt = Base.MethodList(f.name.mt)
for m in mt
if m.ambig !== nothing
Expand Down
2 changes: 1 addition & 1 deletion test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ ambs = detect_ambiguities(Ambig5)

# Test that Core and Base are free of ambiguities
# not using isempty so this prints more information when it fails
@test detect_ambiguities(Core, Base; imported=true, ambiguous_bottom=false) == []
@test detect_ambiguities(Core, Base; imported=true, recursive=true, ambiguous_bottom=false) == []
# some ambiguities involving Union{} type parameters are expected, but not required
@test !isempty(detect_ambiguities(Core, Base; imported=true, ambiguous_bottom=true))

Expand Down

0 comments on commit ac714a1

Please sign in to comment.