diff --git a/base/cmd.jl b/base/cmd.jl index ab639a2b185c8..ecabb5c32b1d0 100644 --- a/base/cmd.jl +++ b/base/cmd.jl @@ -130,7 +130,7 @@ function show(io::IO, cmd::Cmd) print(io, '`') if print_cpus print(io, ", ") - show(io, collect(Int, cmd.cpus)) + show(io, collect(Int, something(cmd.cpus))) print(io, ")") end print_env && (print(io, ","); show(io, cmd.env)) diff --git a/base/deprecated.jl b/base/deprecated.jl index cecda6a1148d2..c4f9699af30ea 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -106,8 +106,13 @@ function depwarn(msg, funcsym; force::Bool=false) _module=begin bt = backtrace() frame, caller = firstcaller(bt, funcsym) - # TODO: Is it reasonable to attribute callers without linfo to Core? - caller.linfo isa Core.MethodInstance ? caller.linfo.def.module : Core + linfo = caller.linfo + if linfo isa Core.MethodInstance + def = linfo.def + def isa Module ? def : def.module + else + Core # TODO: Is it reasonable to attribute callers without linfo to Core? + end end, _file=String(caller.file), _line=caller.line, diff --git a/base/loading.jl b/base/loading.jl index 4441802ab795b..f618c57a966d2 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -599,7 +599,8 @@ end function is_v1_format_manifest(raw_manifest::Dict) if haskey(raw_manifest, "manifest_format") - if raw_manifest["manifest_format"] isa Dict && haskey(raw_manifest["manifest_format"], "uuid") + mf = raw_manifest["manifest_format"] + if mf isa Dict && haskey(mf, "uuid") # the off-chance where an old format manifest has a dep called "manifest_format" return true end @@ -615,7 +616,7 @@ function get_deps(raw_manifest::Dict) return raw_manifest else # if the manifest has no deps, there won't be a `deps` field - return get(Dict{String, Any}, raw_manifest, "deps") + return get(Dict{String, Any}, raw_manifest, "deps")::Dict{String, Any} end end @@ -896,6 +897,7 @@ const TIMING_IMPORTS = Threads.Atomic{Int}(0) if staledeps === true continue end + staledeps = staledeps::Vector{Any} try touch(path_to_try) # update timestamp of precompilation file catch # file might be read-only and then we fail to update timestamp, which is fine @@ -1158,7 +1160,7 @@ function set_pkgorigin_version_path(pkg, path) d = parsed_toml(project_file) v = get(d, "version", nothing) if v !== nothing - pkgorigin.version = VersionNumber(v) + pkgorigin.version = VersionNumber(v::AbstractString) end end end @@ -1307,8 +1309,11 @@ include_string(m::Module, txt::AbstractString, fname::AbstractString="string") = function source_path(default::Union{AbstractString,Nothing}="") s = current_task().storage - if s !== nothing && haskey(s::IdDict{Any,Any}, :SOURCE_PATH) - return s[:SOURCE_PATH]::Union{Nothing,String} + if s !== nothing + s = s::IdDict{Any,Any} + if haskey(s, :SOURCE_PATH) + return s[:SOURCE_PATH]::Union{Nothing,String} + end end return default end @@ -1895,7 +1900,7 @@ function get_preferences_hash(uuid::Union{UUID, Nothing}, prefs_list::Vector{Str for name in prefs_list prefs_value = get(prefs, name, nothing) if prefs_value !== nothing - h = hash(prefs_value, h) + h = hash(prefs_value, h)::UInt end end # We always return a `UInt64` so that our serialization format is stable diff --git a/base/process.jl b/base/process.jl index cbc251ed6dbca..ad7f70ea1875b 100644 --- a/base/process.jl +++ b/base/process.jl @@ -89,7 +89,7 @@ end @noinline function _spawn_primitive(file, cmd::Cmd, stdio::SpawnIOs) loop = eventloop() cpumask = cmd.cpus - cpumask === nothing || (cpumask = as_cpumask(cmd.cpus)) + cpumask === nothing || (cpumask = as_cpumask(cpumask)) GC.@preserve stdio begin iohandles = Tuple{Cint, UInt}[ # assuming little-endian layout let h = rawhandle(io) diff --git a/base/show.jl b/base/show.jl index 8359690034c23..5d2a7dbf913c6 100644 --- a/base/show.jl +++ b/base/show.jl @@ -727,11 +727,11 @@ function show_typealias(io::IO, @nospecialize(x::Type)) end function make_typealiases(@nospecialize(x::Type)) - Any === x && return Core.svec(), Union{} - x <: Tuple && return Core.svec(), Union{} + aliases = SimpleVector[] + Any === x && return aliases, Union{} + x <: Tuple && return aliases, Union{} mods = modulesof!(Set{Module}(), x) Core in mods && push!(mods, Base) - aliases = SimpleVector[] vars = Dict{Symbol,TypeVar}() xenv = UnionAll[] each = Any[] @@ -783,23 +783,24 @@ function make_typealiases(@nospecialize(x::Type)) end end if isempty(aliases) - return Core.svec(), Union{} + return aliases, Union{} end - sort!(aliases, by = x -> x[4], rev = true) # heuristic sort by "best" environment + sort!(aliases, by = x -> x[4]::Tuple{Int,Int}, rev = true) # heuristic sort by "best" environment let applied = Union{} applied1 = Union{} keep = SimpleVector[] prev = (0, 0) for alias in aliases - if alias[4][1] < 2 + alias4 = alias[4]::Tuple{Int,Int} + if alias4[1] < 2 if !(alias[3] <: applied) applied1 = Union{applied1, alias[3]} push!(keep, alias) end - elseif alias[4] == prev || !(alias[3] <: applied) + elseif alias4 == prev || !(alias[3] <: applied) applied = applied1 = Union{applied1, alias[3]} push!(keep, alias) - prev = alias[4] + prev = alias4 end end return keep, applied1 @@ -825,16 +826,17 @@ function show_unionaliases(io::IO, x::Union) end if first && !tvar && length(aliases) == 1 alias = aliases[1] - wheres = make_wheres(io, alias[2], x) - show_typealias(io, alias[1], x, alias[2], wheres) + env = alias[2]::SimpleVector + wheres = make_wheres(io, env, x) + show_typealias(io, alias[1], x, env, wheres) show_wheres(io, wheres) else for alias in aliases print(io, first ? "Union{" : ", ") first = false - env = alias[2] - wheres = make_wheres(io, alias[2], x) - show_typealias(io, alias[1], x, alias[2], wheres) + env = alias[2]::SimpleVector + wheres = make_wheres(io, env, x) + show_typealias(io, alias[1], x, env, wheres) show_wheres(io, wheres) end if tvar @@ -879,7 +881,7 @@ end show(io::IO, @nospecialize(x::Type)) = _show_type(io, inferencebarrier(x)) function _show_type(io::IO, @nospecialize(x::Type)) if print_without_params(x) - show_type_name(io, unwrap_unionall(x).name) + show_type_name(io, (unwrap_unionall(x)::DataType).name) return elseif get(io, :compact, true) && show_typealias(io, x) return @@ -1006,7 +1008,7 @@ function show_datatype(io::IO, x::DataType, wheres::Vector{TypeVar}=TypeVar[]) end else show_type_name(io, x.name) - show_typeparams(io, parameters, unwrap_unionall(x.name.wrapper).parameters, wheres) + show_typeparams(io, parameters, (unwrap_unionall(x.name.wrapper)::DataType).parameters, wheres) end end diff --git a/base/stat.jl b/base/stat.jl index f8d28cadf0c72..f38a82634dc2f 100644 --- a/base/stat.jl +++ b/base/stat.jl @@ -146,7 +146,7 @@ show(io::IO, ::MIME"text/plain", st::StatStruct) = show_statstruct(io, st, false macro stat_call(sym, arg1type, arg) return quote - stat_buf = zeros(UInt8, ccall(:jl_sizeof_stat, Int32, ())) + stat_buf = zeros(UInt8, Int(ccall(:jl_sizeof_stat, Int32, ()))) r = ccall($(Expr(:quote, sym)), Int32, ($(esc(arg1type)), Ptr{UInt8}), $(esc(arg)), stat_buf) if !(r in (0, Base.UV_ENOENT, Base.UV_ENOTDIR, Base.UV_EINVAL)) uv_error(string("stat(", repr($(esc(arg))), ")"), r) diff --git a/base/toml_parser.jl b/base/toml_parser.jl index 66db0e5695551..c19572c2ebaed 100644 --- a/base/toml_parser.jl +++ b/base/toml_parser.jl @@ -1165,7 +1165,7 @@ function parse_string_continue(l::Parser, multiline::Bool, quoted::Bool)::Err{St end function take_chunks(l::Parser, unescape::Bool)::String - nbytes = sum(length, l.chunks) + nbytes = sum(length, l.chunks; init=0) str = Base._string_n(nbytes) offset = 1 for chunk in l.chunks