Skip to content

Commit

Permalink
Bound number of ambiguous methods in stdlib
Browse files Browse the repository at this point in the history
see #27408
  • Loading branch information
tkf committed Aug 22, 2018
1 parent 81b04cf commit e7ff79a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 32 deletions.
66 changes: 34 additions & 32 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,39 @@ end

const tot_time_stdlib = RefValue(0.0)

# Stdlibs manually sorted in top down order
const _stdlibs = [
# No deps
:Base64,
:CRC32c,
:SHA,
:FileWatching,
:Unicode,
:Mmap,
:Serialization,
:Libdl,
:Markdown,
:LibGit2,
:Logging,
:Sockets,
:Printf,
:Profile,
:Dates,
:DelimitedFiles,
:Random,
:UUIDs,
:Future,
:LinearAlgebra,
:SparseArrays,
:SuiteSparse,
:Distributed,
:SharedArrays,
:Pkg,
:Test,
:REPL,
:Statistics,
]

end # baremodule Base

using .Base
Expand All @@ -490,38 +523,7 @@ pushfirst!(Base._included_files, (@__MODULE__, joinpath(@__DIR__, "sysimg.jl")))
if Base.is_primary_base_module
# load some stdlib packages but don't put their names in Main
let
# Stdlibs manually sorted in top down order
stdlibs = [
# No deps
:Base64,
:CRC32c,
:SHA,
:FileWatching,
:Unicode,
:Mmap,
:Serialization,
:Libdl,
:Markdown,
:LibGit2,
:Logging,
:Sockets,
:Printf,
:Profile,
:Dates,
:DelimitedFiles,
:Random,
:UUIDs,
:Future,
:LinearAlgebra,
:SparseArrays,
:SuiteSparse,
:Distributed,
:SharedArrays,
:Pkg,
:Test,
:REPL,
:Statistics,
]
stdlibs = Base._stdlibs

maxlen = maximum(textwidth.(string.(stdlibs)))

Expand Down
21 changes: 21 additions & 0 deletions test/ambiguous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ ambs = detect_ambiguities(Ambig5)
# some ambiguities involving Union{} type parameters are expected, but not required
@test !isempty(detect_ambiguities(Core, Base; imported=true, ambiguous_bottom=true))

module AmbigStdlib
using Test

for lib in Base._stdlibs
@eval import $lib
end

modules = @eval [$(Base._stdlibs...)]

import InteractiveUtils
push!(modules, InteractiveUtils)

# At the moment, there are some method ambiguities in stdlibs. We
# impose a bound to the number of detected ambiguities to avoid
# introducing more ambiguities.
# https://github.com/JuliaLang/julia/issues/27408
@test length(detect_ambiguities(modules...; imported=true, recursive=true)) 2

@test_broken detect_ambiguities(modules...; imported=true, recursive=true) == []
end # module

amb_1(::Int8, ::Int) = 1
amb_1(::Integer, x) = 2
amb_1(x, ::Int) = 3
Expand Down

0 comments on commit e7ff79a

Please sign in to comment.