From e4d933d6b1a9c47fbffc4651488154b517649f65 Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sun, 5 Aug 2018 09:25:44 +0100 Subject: [PATCH] remove more deprecations (#28434) --- base/abstractarray.jl | 8 --- base/abstractdict.jl | 40 ++---------- base/accumulate.jl | 12 +--- base/array.jl | 43 ++----------- base/client.jl | 4 -- base/compiler/typeutils.jl | 4 +- base/deepcopy.jl | 2 +- base/deprecated.jl | 75 ---------------------- base/errorshow.jl | 27 +------- base/file.jl | 27 +------- base/io.jl | 33 ++-------- base/iostream.jl | 6 +- base/libuv.jl | 3 - base/logging.jl | 2 +- base/multidimensional.jl | 6 +- base/process.jl | 6 +- base/sort.jl | 6 +- base/strings/util.jl | 36 ++--------- doc/src/manual/types.md | 2 +- src/builtins.c | 4 -- src/toplevel.c | 6 ++ stdlib/Distributed/src/clusterserialize.jl | 4 +- stdlib/REPL/src/REPLCompletions.jl | 5 -- stdlib/SparseArrays/src/sparsematrix.jl | 5 +- stdlib/SparseArrays/src/sparsevector.jl | 5 +- test/errorshow.jl | 2 +- test/reflection.jl | 2 +- 27 files changed, 55 insertions(+), 320 deletions(-) diff --git a/base/abstractarray.jl b/base/abstractarray.jl index 042e68a9cb856..b60a82b4ab56c 100644 --- a/base/abstractarray.jl +++ b/base/abstractarray.jl @@ -15,14 +15,6 @@ convert(::Type{T}, a::T) where {T<:AbstractArray} = a convert(::Type{AbstractArray{T}}, a::AbstractArray) where {T} = AbstractArray{T}(a) convert(::Type{AbstractArray{T,N}}, a::AbstractArray{<:Any,N}) where {T,N} = AbstractArray{T,N}(a) -if nameof(@__MODULE__) === :Base # avoid method overwrite -# catch undefined constructors before the deprecation kicks in -# TODO: remove when deprecation is removed -function (::Type{T})(arg) where {T<:AbstractArray} - throw(MethodError(T, (arg,))) -end -end - """ size(A::AbstractArray, [dim]) diff --git a/base/abstractdict.jl b/base/abstractdict.jl index c71a98241b719..674e45a5daa22 100644 --- a/base/abstractdict.jl +++ b/base/abstractdict.jl @@ -349,14 +349,10 @@ Dict{Int64,String} with 2 entries: """ function filter!(f, d::AbstractDict) badkeys = Vector{keytype(d)}() - try - for pair in d - # don't delete!(d, k) here, since dictionary types - # may not support mutation during iteration - f(pair) || push!(badkeys, pair.first) - end - catch e - return filter!_dict_deprecation(e, f, d) + for pair in d + # don't delete!(d, k) here, since dictionary types + # may not support mutation during iteration + f(pair) || push!(badkeys, pair.first) end for k in badkeys delete!(d, k) @@ -365,32 +361,10 @@ function filter!(f, d::AbstractDict) end function filter_in_one_pass!(f, d::AbstractDict) - try - for pair in d - if !f(pair) - delete!(d, pair.first) - end + for pair in d + if !f(pair) + delete!(d, pair.first) end - catch e - return filter!_dict_deprecation(e, f, d) - end - return d -end - -function filter!_dict_deprecation(e, f, d::AbstractDict) - if isa(e, MethodError) && e.f === f - depwarn("In `filter!(f, dict)`, `f` is now passed a single pair instead of two arguments.", :filter!) - badkeys = Vector{keytype(d)}() - for (k,v) in d - # don't delete!(d, k) here, since dictionary types - # may not support mutation during iteration - f(k, v) || push!(badkeys, k) - end - for k in badkeys - delete!(d, k) - end - else - rethrow(e) end return d end diff --git a/base/accumulate.jl b/base/accumulate.jl index ea55a07906941..1f30250f44ee5 100644 --- a/base/accumulate.jl +++ b/base/accumulate.jl @@ -86,11 +86,7 @@ julia> cumsum(a, dims=2) 4 9 15 ``` """ -function cumsum(A::AbstractArray{T}; dims::Union{Nothing,Integer}=nothing) where T - if dims === nothing - depwarn("`cumsum(A::AbstractArray)` is deprecated, use `cumsum(A, dims=1)` instead.", :cumsum) - dims = 1 - end +function cumsum(A::AbstractArray{T}; dims::Integer) where T out = similar(A, promote_op(add_sum, T, T)) cumsum!(out, A, dims=dims) end @@ -162,11 +158,7 @@ julia> cumprod(a, dims=2) 4 20 120 ``` """ -function cumprod(A::AbstractArray; dims::Union{Nothing,Integer}=nothing) - if dims === nothing - depwarn("`cumprod(A::AbstractArray)` is deprecated, use `cumprod(A, dims=1)` instead.", :cumprod) - dims = 1 - end +function cumprod(A::AbstractArray; dims::Integer) return accumulate(mul_prod, A, dims=dims) end diff --git a/base/array.jl b/base/array.jl index 4e6e5371b095d..7559c29ab1d9d 100644 --- a/base/array.jl +++ b/base/array.jl @@ -1606,14 +1606,8 @@ CartesianIndex(2, 1) function findnext(A, start) l = last(keys(A)) i = start - warned = false while i <= l - a = A[i] - if !warned && !(a isa Bool) - depwarn("In the future `findnext` will only work on boolean collections. Use `findnext(x->x!=0, A, start)` instead.", :findnext) - warned = true - end - if a != 0 + if A[i] return i end i = nextind(A, i) @@ -1655,13 +1649,8 @@ CartesianIndex(2, 1) ``` """ function findfirst(A) - warned = false for (i, a) in pairs(A) - if !warned && !(a isa Bool) - depwarn("In the future `findfirst` will only work on boolean collections. Use `findfirst(x->x!=0, A)` instead.", :findfirst) - warned = true - end - if a != 0 + if a return i end end @@ -1695,9 +1684,7 @@ julia> findnext(isodd, A, CartesianIndex(1, 1)) CartesianIndex(1, 1) ``` """ -@inline findnext(testf::Function, A, start) = findnext_internal(testf, A, start) - -function findnext_internal(testf::Function, A, start) +function findnext(testf::Function, A, start) l = last(keys(A)) i = start while i <= l @@ -1789,14 +1776,8 @@ CartesianIndex(2, 1) """ function findprev(A, start) i = start - warned = false while i >= first(keys(A)) - a = A[i] - if !warned && !(a isa Bool) - depwarn("In the future `findprev` will only work on boolean collections. Use `findprev(x->x!=0, A, start)` instead.", :findprev) - warned = true - end - a != 0 && return i + A[i] && return i i = prevind(A, i) end return nothing @@ -1837,13 +1818,8 @@ CartesianIndex(2, 1) ``` """ function findlast(A) - warned = false for (i, a) in Iterators.reverse(pairs(A)) - if !warned && !(a isa Bool) - depwarn("In the future `findlast` will only work on boolean collections. Use `findlast(x->x!=0, A)` instead.", :findlast) - warned = true - end - if a != 0 + if a return i end end @@ -1885,9 +1861,7 @@ julia> findprev(isodd, A, CartesianIndex(1, 2)) CartesianIndex(2, 1) ``` """ -@inline findprev(testf::Function, A, start) = findprev_internal(testf, A, start) - -function findprev_internal(testf::Function, A, start) +function findprev(testf::Function, A, start) i = start while i >= first(keys(A)) testf(A[i]) && return i @@ -2031,10 +2005,7 @@ julia> findall(falses(3)) ``` """ function findall(A) - if !(eltype(A) === Bool) && !all(x -> x isa Bool, A) - depwarn("In the future `findall(A)` will only work on boolean collections. Use `findall(x->x!=0, A)` instead.", :find) - end - collect(first(p) for p in pairs(A) if last(p) != 0) + collect(first(p) for p in pairs(A) if last(p)) end # Allocating result upfront is faster (possible only when collection can be iterated twice) function findall(A::AbstractArray{Bool}) diff --git a/base/client.jl b/base/client.jl index 1c82f3d453e81..0f9e97cee7682 100644 --- a/base/client.jl +++ b/base/client.jl @@ -163,10 +163,6 @@ function parse_input_line(s::String; filename::String="none", depwarn=true) s, sizeof(s), filename, sizeof(filename)) end end - if ex isa Symbol && all(isequal('_'), string(ex)) - # remove with 0.7 deprecation - Meta.lower(Main, ex) # to get possible warning about using _ as an rvalue - end return ex end parse_input_line(s::AbstractString) = parse_input_line(String(s)) diff --git a/base/compiler/typeutils.jl b/base/compiler/typeutils.jl index f757be6321156..4c5bf9dfe1069 100644 --- a/base/compiler/typeutils.jl +++ b/base/compiler/typeutils.jl @@ -48,11 +48,11 @@ end function valid_tparam(@nospecialize(x)) if isa(x, Tuple) for t in x - isa(t, Symbol) || isbitstype(typeof(t)) || return false + isa(t, Symbol) || isbits(t) || return false end return true end - return isa(x, Symbol) || isbitstype(typeof(x)) + return isa(x, Symbol) || isbits(x) end # return an upper-bound on type `a` with type `b` removed diff --git a/base/deepcopy.jl b/base/deepcopy.jl index 09c6e559e35ee..7ed68bbf2b6ac 100644 --- a/base/deepcopy.jl +++ b/base/deepcopy.jl @@ -87,7 +87,7 @@ function _deepcopy_array_t(@nospecialize(x), T, stackdict::IdDict) for i = 1:(length(x)::Int) if ccall(:jl_array_isassigned, Cint, (Any, Csize_t), x, i-1) != 0 xi = ccall(:jl_arrayref, Any, (Any, Csize_t), x, i-1) - if !isbitstype(typeof(xi)) + if !isbits(xi) xi = deepcopy_internal(xi, stackdict) end ccall(:jl_arrayset, Cvoid, (Any, Any, Csize_t), dest, xi, i-1) diff --git a/base/deprecated.jl b/base/deprecated.jl index d1375f403fce8..e5228e5fa4ebd 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -187,8 +187,6 @@ end # BEGIN 0.7 deprecations -# TODO: remove warning for using `_` in parse_input_line in base/client.jl - @deprecate issubtype (<:) @deprecate union() Set() @@ -347,9 +345,6 @@ end @deprecate momenttype(::Type{T}) where {T} typeof((zero(T)*zero(T) + zero(T)*zero(T))/2) false -# issue #6466 -# `write` on non-isbits arrays is deprecated in io.jl. - # PR #23187 @deprecate cpad(s, n::Integer, p=" ") rpad(lpad(s, div(n+textwidth(s), 2), p), n, p) false @@ -404,22 +399,6 @@ end @deprecate (convert(::Type{Integer}, x::Enum{T}) where {T<:Integer}) Integer(x) @deprecate (convert(::Type{T}, x::Enum{T2}) where {T<:Integer,T2<:Integer}) T(x) -function (::Type{T})(arg) where {T} - if applicable(convert, T, arg) - sig = which(convert, (Type{T}, typeof(arg))).sig - if sig == (Tuple{typeof(convert),Type{S},Number} where S<:Number) || - sig == (Tuple{typeof(convert),Type{S},AbstractArray} where S<:AbstractArray) - # matches a catch-all converter; will stack overflow - throw(MethodError(T, (arg,))) - end - # if `convert` call would not work, just let the method error happen - depwarn("Constructors no longer fall back to `convert`. A constructor `$T(::$(typeof(arg)))` should be defined instead.", :Type) - end - convert(T, arg)::T -end -# related items to remove in: abstractarray.jl, dates/periods.jl, compiler.jl -# also remove all uses of is_default_method - @deprecate convert(::Type{UInt128}, u::UUID) UInt128(u) @deprecate convert(::Type{UUID}, s::AbstractString) UUID(s) @@ -430,12 +409,6 @@ end @deprecate rol!(dest, src, i) circshift!(dest, src, -i) @deprecate rol!(B, i) circshift!(B, -i) -# issue #5148, PR #23259 -# warning for `const` on locals should be changed to an error in julia-syntax.scm - -# issue #17886 -# deprecations for filter[!] with 2-arg functions are in abstractdict.jl - # PR #23066 @deprecate cfunction(f, r, a::Tuple) cfunction(f, r, Tuple{a...}) @noinline function cfunction(f, r, a) @@ -487,8 +460,6 @@ end @deprecate selectperm partialsortperm @deprecate selectperm! partialsortperm! -# `initialized` keyword arg to `sort` is deprecated in sort.jl - @deprecate promote_noncircular promote false import .Iterators.enumerate @@ -655,18 +626,6 @@ end @deprecate strwidth textwidth @deprecate charwidth textwidth -@deprecate find(x::Number) findall(!iszero, x) -@deprecate findnext(A, v, i::Integer) something(findnext(isequal(v), A, i), 0) -@deprecate findfirst(A, v) something(findfirst(isequal(v), A), 0) -@deprecate findprev(A, v, i::Integer) something(findprev(isequal(v), A, i), 0) -@deprecate findlast(A, v) something(findlast(isequal(v), A), 0) -# to fix ambiguities introduced by deprecations -# TODO: also remove find*_internal in array.jl -findnext(pred::Function, A, i::Integer) = findnext_internal(pred, A, i) -findprev(pred::Function, A, i::Integer) = findprev_internal(pred, A, i) -# also remove deprecation warnings in find* functions in array.jl, sparse/sparsematrix.jl, -# and sparse/sparsevector.jl. - # issue #22849 @deprecate reinterpret(::Type{T}, a::Array{S}, dims::NTuple{N,Int}) where {T, S, N} reshape(reinterpret(T, vec(a)), dims) @deprecate reinterpret(::Type{T}, a::ReinterpretArray{S}, dims::NTuple{N,Int}) where {T, S, N} reshape(reinterpret(T, vec(a)), dims) @@ -713,9 +672,6 @@ findprev(pred::Function, A, i::Integer) = findprev_internal(pred, A, i) @deprecate parse(str::AbstractString, pos::Int, ; kwargs...) Meta.parse(str, pos; kwargs...) @deprecate_binding ParseError Meta.ParseError -# cumsum and cumprod have deprecations in multidimensional.jl -# when the message is removed, the `dims` keyword argument should become required. - # issue #16307 @deprecate finalizer(o, f::Function) finalizer(f, o) # This misses other callables but they are very rare in the wild @@ -1209,16 +1165,6 @@ end @deprecate findin(a, b) findall(in(b), a) -@deprecate find findall -@deprecate find(A::AbstractVector) findall(A) -@deprecate find(A::AbstractArray) LinearIndices(A)[findall(A)] -@deprecate find(f::Function, A::AbstractVector) findall(f, A) -@deprecate find(f::Function, A::AbstractArray) LinearIndices(A)[findall(f, A)] - -@deprecate findn(x::AbstractVector) (findall(!iszero, x),) -@deprecate findn(x::AbstractMatrix) (I = findall(!iszero, x); (getindex.(I, 1), getindex.(I, 2))) -@deprecate findn(x::AbstractArray{T, N}) where {T, N} (I = findall(!iszero, x); ntuple(i -> getindex.(I, i), N)) - @deprecate catch_stacktrace(c_funcs::Bool) stacktrace(catch_backtrace(), c_funcs) @deprecate catch_stacktrace() stacktrace(catch_backtrace()) @@ -1413,12 +1359,6 @@ end # PR #23332 @deprecate ^(x, p::Integer) Base.power_by_squaring(x,p) -# Issue #25979 -# The `remove_destination` keyword to `cp`, `mv`, and the unexported `cptree` has been -# renamed to `force`. To remove this deprecation, remove the `remove_destination` keyword -# argument from the function signatures as well as the internal logic that deals with the -# renaming. These live in base/file.jl. - # issue #25928 @deprecate wait(t::Task) fetch(t) @@ -1468,10 +1408,6 @@ end # Issue #25786 @deprecate_binding DevNull devnull -# TODO: When these are removed, also remove the uppercase variants in libuv.jl and stream.jl -@deprecate_binding STDIN stdin true nothing false -@deprecate_binding STDOUT stdout true nothing false -@deprecate_binding STDERR stderr true nothing false # PR 25062 @deprecate(link_pipe(pipe; julia_only_read = true, julia_only_write = true), @@ -1507,9 +1443,6 @@ end @deprecate(matchall(r::Regex, s::AbstractString; overlap::Bool = false), collect(m.match for m in eachmatch(r, s, overlap = overlap))) -# remove depwarn for `diff` in multidimensional.jl -# @deprecate diff(A::AbstractMatrix) diff(A, dims=1) - # PR 26194 export assert function assert(x) @@ -1603,14 +1536,6 @@ end @deprecate linearindices(x::AbstractArray) LinearIndices(x) -# PR #26647 -# The `keep` argument in `split` and `rpslit` has been renamed to `keepempty`. -# To remove this deprecation, remove the `keep` argument from the function signatures as well as -# the internal logic that deals with the renaming. These live in base/strings/util.jl. - -# when this is removed, `isbitstype(typeof(x))` can be replaced with `isbits(x)` -@deprecate isbits(@nospecialize(t::Type)) isbitstype(t) - # Special string deprecation @deprecate start(s::AbstractString) firstindex(s) @deprecate next(s::AbstractString, i::Integer) iterate(s, i) diff --git a/base/errorshow.jl b/base/errorshow.jl index ea2037d541685..a590a04eeee4b 100644 --- a/base/errorshow.jl +++ b/base/errorshow.jl @@ -187,7 +187,9 @@ function showerror(io::IO, ex::MethodError) else print(io, "Cannot `convert` an object of type ", arg_types_param[2], " to an object of type ", T) end - elseif isempty(methods(f)) && !isa(f, Function) + elseif isempty(methods(f)) && isa(f, DataType) && f.abstract + print(io, "no constructors have been defined for $f") + elseif isempty(methods(f)) && !isa(f, Function) && !isa(f, Type) print(io, "objects of type $ft are not callable") else if ft <: Function && isempty(ft.parameters) && @@ -196,18 +198,6 @@ function showerror(io::IO, ex::MethodError) f_is_function = true print(io, "no method matching ", name) elseif isa(f, Type) - if isa(f, DataType) && f.abstract - # Print a more appropriate message if the only method - # on the type is the default one from sysimg.jl. - ms = methods(f) - if length(ms) == 1 - m = first(ms) - if Base.is_default_method(m) - print(io, "no constructors have been defined for $f") - return - end - end - end print(io, "no method matching ", f) else print(io, "no method matching (::", ft, ")") @@ -328,9 +318,6 @@ function show_method_candidates(io::IO, ex::MethodError, @nospecialize kwargs=() iob = IOContext(buf, io) tv = Any[] sig0 = method.sig - if Base.is_default_method(method) - continue - end while isa(sig0, UnionAll) push!(tv, sig0.var) sig0 = sig0.body @@ -621,14 +608,6 @@ function process_backtrace(t::Vector, limit::Int=typemax(Int); skipC = true) return ret end -""" -Determines whether a method is the default method which is provided to all types from sysimg.jl. -Such a method is usually undesirable to be displayed to the user in the REPL. -""" -function is_default_method(m::Method) - return m.module == Base && m.sig == Tuple{Type{T},Any} where T -end - @noinline function throw_eachindex_mismatch(::IndexLinear, A...) throw(DimensionMismatch("all inputs to eachindex must have the same indices, got $(join(LinearIndices.(A), ", ", " and "))")) end diff --git a/base/file.jl b/base/file.jl index 393ee046803ac..1fab5238bc745 100644 --- a/base/file.jl +++ b/base/file.jl @@ -297,14 +297,7 @@ function checkfor_mv_cp_cptree(src::AbstractString, dst::AbstractString, txt::Ab end function cptree(src::AbstractString, dst::AbstractString; force::Bool=false, - follow_symlinks::Bool=false, - remove_destination::Union{Bool,Nothing}=nothing) - # TODO: Remove after 0.7 - if remove_destination !== nothing - Base.depwarn("The `remove_destination` keyword argument is deprecated; use " * - "`force` instead", :cptree) - force = remove_destination - end + follow_symlinks::Bool=false) isdir(src) || throw(ArgumentError("'$src' is not a directory. Use `cp(src, dst)`")) checkfor_mv_cp_cptree(src, dst, "copying"; force=force) mkdir(dst) @@ -333,14 +326,7 @@ of the file or directory `src` refers to. Return `dst`. """ function cp(src::AbstractString, dst::AbstractString; force::Bool=false, - follow_symlinks::Bool=false, - remove_destination::Union{Bool,Nothing}=nothing) - # TODO: Remove after 0.7 - if remove_destination !== nothing - Base.depwarn("The `remove_destination` keyword argument is deprecated; use " * - "`force` instead", :cp) - force = remove_destination - end + follow_symlinks::Bool=false) checkfor_mv_cp_cptree(src, dst, "copying"; force=force) if !follow_symlinks && islink(src) symlink(readlink(src), dst) @@ -387,14 +373,7 @@ julia> rm("goodbye.txt"); ``` """ -function mv(src::AbstractString, dst::AbstractString; force::Bool=false, - remove_destination::Union{Bool,Nothing}=nothing) - # TODO: Remove after 0.7 - if remove_destination !== nothing - Base.depwarn("The `remove_destination` keyword argument is deprecated; use " * - "`force` instead", :mv) - force = remove_destination - end +function mv(src::AbstractString, dst::AbstractString; force::Bool=false) checkfor_mv_cp_cptree(src, dst, "moving"; force=force) rename(src, dst) dst diff --git a/base/io.jl b/base/io.jl index df0bf364682d3..41f4ec8258ca4 100644 --- a/base/io.jl +++ b/base/io.jl @@ -355,21 +355,13 @@ julia> readline("my_file.txt", keep=true) julia> rm("my_file.txt") ``` """ -function readline(filename::AbstractString; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `readline` is deprecated in favor of `keep=$keep`.", :readline) - end +function readline(filename::AbstractString; keep::Bool=false) open(filename) do f readline(f, keep=keep) end end -function readline(s::IO=stdin; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `readline` is deprecated in favor of `keep=$keep`.", :readline) - end +function readline(s::IO=stdin; keep::Bool=false) line = readuntil(s, 0x0a, keep=true) i = length(line) if keep || i == 0 || line[i] != 0x0a @@ -521,7 +513,7 @@ write(to::IO, p::Ptr) = write(to, convert(UInt, p)) function write(s::IO, A::AbstractArray) if !isbitstype(eltype(A)) - depwarn("Calling `write` on non-isbits arrays is deprecated. Use a loop or `serialize` instead.", :write) + error("`write` is not supported on non-isbits arrays") end nb = 0 for a in A @@ -534,12 +526,7 @@ function write(s::IO, a::Array) if isbitstype(eltype(a)) return GC.@preserve a unsafe_write(s, pointer(a), sizeof(a)) else - depwarn("Calling `write` on non-isbits arrays is deprecated. Use a loop or `serialize` instead.", :write) - nb = 0 - for b in a - nb += write(s, b) - end - return nb + error("`write` is not supported on non-isbits arrays") end end @@ -875,19 +862,11 @@ JuliaLang is a GitHub organization. It has many members. julia> rm("my_file.txt"); ``` """ -function eachline(stream::IO=stdin; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) - end +function eachline(stream::IO=stdin; keep::Bool=false) EachLine(stream, keep=keep)::EachLine end -function eachline(filename::AbstractString; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) - end +function eachline(filename::AbstractString; keep::Bool=false) s = open(filename) EachLine(s, ondone=()->close(s), keep=keep)::EachLine end diff --git a/base/iostream.jl b/base/iostream.jl index c6f11fa0f75a4..8454a1e330175 100644 --- a/base/iostream.jl +++ b/base/iostream.jl @@ -425,11 +425,7 @@ function readuntil_string(s::IOStream, delim::UInt8, keep::Bool) ccall(:jl_readuntil, Ref{String}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, delim, 1, !keep) end -function readline(s::IOStream; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `readline` is deprecated in favor of `keep=$keep`.", :readline) - end +function readline(s::IOStream; keep::Bool=false) ccall(:jl_readuntil, Ref{String}, (Ptr{Cvoid}, UInt8, UInt8, UInt8), s.ios, '\n', 1, keep ? 0 : 2) end diff --git a/base/libuv.jl b/base/libuv.jl index 1102148c11906..31ea116fba0a6 100644 --- a/base/libuv.jl +++ b/base/libuv.jl @@ -120,9 +120,6 @@ function reinit_stdio() global stdin = init_stdio(ccall(:jl_stdin_stream, Ptr{Cvoid}, ())) global stdout = init_stdio(ccall(:jl_stdout_stream, Ptr{Cvoid}, ())) global stderr = init_stdio(ccall(:jl_stderr_stream, Ptr{Cvoid}, ())) - global STDIN = stdin - global STDOUT = stdout - global STDERR = stderr end """ diff --git a/base/logging.jl b/base/logging.jl index 862c68fbf0813..c3570469a90fb 100644 --- a/base/logging.jl +++ b/base/logging.jl @@ -341,7 +341,7 @@ end handle_message(logger, Error, msg, _module, :logevent_error, id, filepath, line; exception=(err,catch_backtrace())) catch err2 try - # Give up and write to STDERR, in three independent calls to + # Give up and write to stderr, in three independent calls to # increase the odds of it getting through. print(stderr, "Exception handling log message: ") println(stderr, err) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index d69be1e315bdd..19d2b60b90d7f 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -684,11 +684,7 @@ julia> diff(vec(a)) 12 ``` """ -function diff(A::AbstractMatrix; dims::Union{Integer,Nothing}=nothing) - if dims === nothing - depwarn("`diff(A::AbstractMatrix)` is deprecated, use `diff(A, dims=1)` instead.", :diff) - dims = 1 - end +function diff(A::AbstractMatrix; dims::Integer) if dims == 1 [A[i+1,j] - A[i,j] for i=1:size(A,1)-1, j=1:size(A,2)] elseif dims == 2 diff --git a/base/process.jl b/base/process.jl index 5fab124004178..df5c321daab7e 100644 --- a/base/process.jl +++ b/base/process.jl @@ -551,11 +551,7 @@ spawn_opts_inherit(in::Redirectable=RawFD(0), out::Redirectable=RawFD(1), err::R _spawn(cmds::AbstractCmd, args...; chain::Union{ProcessChain, Nothing}=nothing) = _spawn(cmds, spawn_opts_swallow(args...)...; chain=chain) -function eachline(cmd::AbstractCmd; chomp=nothing, keep::Bool=false) - if chomp !== nothing - keep = !chomp - depwarn("The `chomp=$chomp` argument to `eachline` is deprecated in favor of `keep=$keep`.", :eachline) - end +function eachline(cmd::AbstractCmd; keep::Bool=false) _stdout = Pipe() processes = _spawn(cmd, (devnull, _stdout, stderr)) close(_stdout.in) diff --git a/base/sort.jl b/base/sort.jl index eb5c47573ce99..3f395c6329e11 100644 --- a/base/sort.jl +++ b/base/sort.jl @@ -902,12 +902,8 @@ function sort(A::AbstractArray; lt=isless, by=identity, rev::Union{Bool,Nothing}=nothing, - order::Ordering=Forward, - initialized::Union{Bool,Nothing}=nothing) + order::Ordering=Forward) dim = dims - if initialized !== nothing - Base.depwarn("`initialized` keyword argument is deprecated", :sort) - end order = ord(lt,by,rev,order) n = length(axes(A, dim)) if dim != 1 diff --git a/base/strings/util.jl b/base/strings/util.jl index f8214eb0f2c2a..fc473568646ec 100644 --- a/base/strings/util.jl +++ b/base/strings/util.jl @@ -302,27 +302,15 @@ julia> split(a,".") function split end function split(str::T, splitter; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :split) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _split(str, splitter, limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end function split(str::T, splitter::Union{Tuple{Vararg{<:AbstractChar}},AbstractVector{<:AbstractChar},Set{<:AbstractChar}}; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :split) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _split(str, in(splitter), limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end function split(str::T, splitter::AbstractChar; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :split) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _split(str, isequal(splitter), limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end @@ -388,27 +376,15 @@ julia> rsplit(a,".";limit=2) function rsplit end function rsplit(str::T, splitter; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :rsplit) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _rsplit(str, splitter, limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end function rsplit(str::T, splitter::Union{Tuple{Vararg{<:AbstractChar}},AbstractVector{<:AbstractChar},Set{<:AbstractChar}}; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :rsplit) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _rsplit(str, in(splitter), limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end function rsplit(str::T, splitter::AbstractChar; - limit::Integer=0, keepempty::Bool=true, keep::Union{Nothing,Bool}=nothing) where {T<:AbstractString} - if keep !== nothing - Base.depwarn("The `keep` keyword argument is deprecated; use `keepempty` instead", :rsplit) - keepempty = keep - end + limit::Integer=0, keepempty::Bool=true) where {T<:AbstractString} _rsplit(str, isequal(splitter), limit, keepempty, T <: SubString ? T[] : SubString{T}[]) end diff --git a/doc/src/manual/types.md b/doc/src/manual/types.md index 138669aa609f7..7cd8c58b21542 100644 --- a/doc/src/manual/types.md +++ b/doc/src/manual/types.md @@ -657,7 +657,7 @@ For the default constructor, exactly one argument must be supplied for each fiel ```jldoctest pointtype julia> Point{Float64}(1.0) -ERROR: MethodError: Cannot `convert` an object of type Float64 to an object of type Point{Float64} +ERROR: MethodError: no method matching Point{Float64}(::Float64) [...] julia> Point{Float64}(1.0,2.0,3.0) diff --git a/src/builtins.c b/src/builtins.c index 9efe6c60c50f4..2fa6c47afc2f7 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -601,10 +601,6 @@ JL_CALLABLE(jl_f__apply_latest) JL_DLLEXPORT jl_value_t *jl_toplevel_eval_in(jl_module_t *m, jl_value_t *ex) { jl_ptls_t ptls = jl_get_ptls_states(); - if (m == NULL) - m = jl_main_module; - if (jl_is_symbol(ex)) - return jl_eval_global_var(m, (jl_sym_t*)ex); if (ptls->in_pure_callback) jl_error("eval cannot be used in a generated function"); jl_value_t *v = NULL; diff --git a/src/toplevel.c b/src/toplevel.c index 7605ddc7d542a..724ab13c30a03 100644 --- a/src/toplevel.c +++ b/src/toplevel.c @@ -590,6 +590,12 @@ jl_value_t *jl_toplevel_eval_flex(jl_module_t *m, jl_value_t *e, int fast, int e jl_lineno = jl_linenode_line(e); return jl_nothing; } + if (jl_is_symbol(e)) { + char *n = jl_symbol_name((jl_sym_t*)e); + while (*n == '_') ++n; + if (*n == 0) + jl_error("all-underscore identifier used as rvalue"); + } return jl_interpret_toplevel_expr_in(m, e, NULL, NULL); } diff --git a/stdlib/Distributed/src/clusterserialize.jl b/stdlib/Distributed/src/clusterserialize.jl index fd584afc2b8f5..f50ae77027d1f 100644 --- a/stdlib/Distributed/src/clusterserialize.jl +++ b/stdlib/Distributed/src/clusterserialize.jl @@ -126,7 +126,7 @@ function syms_2b_sent(s::ClusterSerializer, identifier) for sym in check_syms v = getfield(Main, sym) - if isbitstype(typeof(v)) + if isbits(v) push!(lst, sym) else oid = objectid(v) @@ -146,7 +146,7 @@ function serialize_global_from_main(s::ClusterSerializer, sym) oid = objectid(v) record_v = true - if isbitstype(typeof(v)) + if isbits(v) record_v = false elseif !haskey(s.glbs_sent, oid) # set up a finalizer the first time this object is sent diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index 5cd1e5b310087..3a3e507c9162a 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -444,11 +444,6 @@ function complete_methods(ex_org::Expr, context_module=Main)::Vector{Completion} for method in ml ms = method.sig - # Do not suggest the default method from sysimg.jl. - if Base.is_default_method(method) - continue - end - # Check if the method's type signature intersects the input types if typeintersect(Base.rewrap_unionall(Tuple{Base.unwrap_unionall(ms).parameters[1 : min(na, end)]...}, ms), t_in) != Union{} push!(out, MethodCompletion(func, t_in, method, kwtype)) diff --git a/stdlib/SparseArrays/src/sparsematrix.jl b/stdlib/SparseArrays/src/sparsematrix.jl index e85a58add870c..9af2d259dadff 100644 --- a/stdlib/SparseArrays/src/sparsematrix.jl +++ b/stdlib/SparseArrays/src/sparsematrix.jl @@ -1306,10 +1306,7 @@ dropzeros(A::SparseMatrixCSC; trim::Bool = true) = dropzeros!(copy(A), trim = tr ## Find methods function findall(S::SparseMatrixCSC) - if !(eltype(S) <: Bool) - Base.depwarn("In the future `findall(A)` will only work on boolean collections. Use `findall(x->x!=0, A)` instead.", :findall) - end - return findall(x->x!=0, S) + return findall(identity, S) end function findall(p::Function, S::SparseMatrixCSC) diff --git a/stdlib/SparseArrays/src/sparsevector.jl b/stdlib/SparseArrays/src/sparsevector.jl index 3604b3f65fcbf..124453fe7374d 100644 --- a/stdlib/SparseArrays/src/sparsevector.jl +++ b/stdlib/SparseArrays/src/sparsevector.jl @@ -688,10 +688,7 @@ function getindex(A::SparseMatrixCSC{Tv,Ti}, I::AbstractVector) where {Tv,Ti} end function findall(x::SparseVector) - if !(eltype(x) <: Bool) - Base.depwarn("In the future `findall(A)` will only work on boolean collections. Use `findall(x->x!=0, A)` instead.", :findall) - end - return findall(x->x!=0, x) + return findall(identity, x) end function findall(p::Function, x::SparseVector{<:Any,Ti}) where Ti diff --git a/test/errorshow.jl b/test/errorshow.jl index ca3a52b72563e..f8f29c659d2b6 100644 --- a/test/errorshow.jl +++ b/test/errorshow.jl @@ -212,7 +212,7 @@ err_str = @except_str Float64[](1) MethodError @test !occursin("import Base.Array", err_str) Array() = 1 -err_str = @except_str Array(1) MethodError +err_str = @except_str Array([1]) MethodError @test occursin("import Base.Array", err_str) end diff --git a/test/reflection.jl b/test/reflection.jl index ceaabc89c724b..0e0e1fe3bc634 100644 --- a/test/reflection.jl +++ b/test/reflection.jl @@ -266,7 +266,7 @@ import Base: datatype_alignment, return_types @test datatype_alignment(UInt16) == 2 @test datatype_alignment(TLayout) == 4 let rts = return_types(TLayout) - @test length(rts) >= 3 # general constructor, specific constructor, and call-to-convert adapter(s) + @test length(rts) == 2 # general constructor and specific constructor @test all(rts .== TLayout) end