Skip to content

Commit

Permalink
Remove compat code undef from #417 and #514
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 8, 2019
1 parent 4384180 commit 8b628e7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 43 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,6 @@ Currently, the `@compat` macro supports the following syntaxes:

* `isnothing` for testing if a variable is equal to `nothing` ([#29674]).

* `UndefInitializer` and `undef` with corresponding `Array` constructors ([#24652], [#26316]).

* `BitArray` constructors for `undef` ([#24785], [#26316]).

* `@compat finalizer(func, obj)` with the finalizer to run as the first argument and the object to be finalized
as the second ([#24605]).

Expand Down
27 changes: 0 additions & 27 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,6 @@ import Base64

include("compatmacro.jl")

# 0.7.0-DEV.4527
@static if !isdefined(Base, :UndefInitializer)
import Base: Array, Matrix, Vector
@static if isdefined(Base, :Uninitialized)
useuninit(args) = (Base.uninitialized, args...)
else
useuninit(args) = args
end
struct UndefInitializer end
const undef = UndefInitializer()
export undef, UndefInitializer
Base.show(io::IO, ::UndefInitializer) =
print(io, "array initializer with undefined values")
Array{T}(::UndefInitializer, args...) where {T} = Array{T}(useuninit(args)...)
Array{T,N}(::UndefInitializer, args...) where {T,N} = Array{T,N}(useuninit(args)...)
Vector(::UndefInitializer, args...) = Vector(useuninit(args)...)
Matrix(::UndefInitializer, args...) = Matrix(useuninit(args)...)

BitArray{N}(::UndefInitializer, args...) where {N} = BitArray{N}(useuninit(args)...)
BitArray(::UndefInitializer, args...) = BitArray(useuninit(args)...)
end
@static if VERSION < v"0.7.0-DEV.2581"
export uninitialized, Uninitialized
const uninitialized = undef
const Uninitialized = UndefInitializer
end

# 0.7.0-DEV.1499
if VERSION < v"0.7.0-DEV.1499"
function Base.get(f::Base.Callable, ::Base.EnvHash, k::AbstractString)
Expand Down
12 changes: 12 additions & 0 deletions test/old.jl
Original file line number Diff line number Diff line change
Expand Up @@ -520,3 +520,15 @@ end
# 0.7.0-DEV.1472
@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true, :arg3=>true), :arg3, false)
@test get(IOContext(IOBuffer(), :arg1=>true, :arg2=>true), :arg2, false)

# 0.7.0-DEV.2581, 0.7.0-DEV.4527
@test isa(Vector(undef, 2), Vector{Any})
@test isa(Vector{Float64}(undef, 2), Vector{Float64})
@test isa(Matrix(undef, 2, 2), Matrix{Any})
@test isa(Matrix{Float64}(undef, 2, 2), Matrix{Float64})
@test isa(Array{Float64}(undef, 2, 2), Matrix{Float64})
@test isa(Array{Float64,3}(undef, 2, 2, 2), Array{Float64,3})

# 0.7.0-DEV.2687, 0.7.0-DEV.4527
@test isa(BitVector(undef, 2), BitVector)
@test isa(BitArray(undef, 2, 2), BitMatrix)
12 changes: 0 additions & 12 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,6 @@ end
@test textwidth("A") == 1
@test textwidth('A') == 1

# 0.7.0-DEV.2581, 0.7.0-DEV.4527
@test isa(Vector(undef, 2), Vector{Any})
@test isa(Vector{Float64}(undef, 2), Vector{Float64})
@test isa(Matrix(undef, 2, 2), Matrix{Any})
@test isa(Matrix{Float64}(undef, 2, 2), Matrix{Float64})
@test isa(Array{Float64}(undef, 2, 2), Matrix{Float64})
@test isa(Array{Float64,3}(undef, 2, 2, 2), Array{Float64,3})

# 0.7.0-DEV.2687, 0.7.0-DEV.4527
@test isa(BitVector(undef, 2), BitVector)
@test isa(BitArray(undef, 2, 2), BitMatrix)

# 0.7
let A = [1]
local x = 0
Expand Down

0 comments on commit 8b628e7

Please sign in to comment.