From 75ba566bb658e7979a4a19dc2f1c124ebb9a898e Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Sat, 5 Aug 2017 13:29:28 -0400 Subject: [PATCH] deprecate `union()` --- NEWS.md | 3 +++ base/deprecated.jl | 2 ++ base/set.jl | 1 - test/sets.jl | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 104a4b49500ae..29cf728efc970 100644 --- a/NEWS.md +++ b/NEWS.md @@ -262,6 +262,9 @@ Deprecated or removed full path if you need access to executables or libraries in the `JULIA_HOME` directory, e.g. `joinpath(JULIA_HOME, "7z.exe")` for `7z.exe` ([#21540]). + * Calling `union` with no arguments is deprecated; construct an empty set with an appropriate + element type using `Set{T}()` instead ([#23144]). + Julia v0.6.0 Release Notes ========================== diff --git a/base/deprecated.jl b/base/deprecated.jl index bd90c1497825d..5e63afcff4a1e 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1334,6 +1334,8 @@ end @deprecate issubtype (<:) +@deprecate union() Set() + # 12807 start(::Union{Process, ProcessChain}) = 1 done(::Union{Process, ProcessChain}, i::Int) = (i == 3) diff --git a/base/set.jl b/base/set.jl index c0d18af570d61..7d79287e4abe2 100644 --- a/base/set.jl +++ b/base/set.jl @@ -65,7 +65,6 @@ done(s::Set, state) = done(s.dict, state) # NOTE: manually optimized to take advantage of Dict representation next(s::Set, i) = (s.dict.keys[i], skip_deleted(s.dict, i+1)) -union() = Set() union(s::Set) = copy(s) function union(s::Set, sets::Set...) u = Set{join_eltype(s, sets...)}() diff --git a/test/sets.jl b/test/sets.jl index 8808036301acb..6e62708f64ced 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -138,7 +138,6 @@ for data_in in ((7,8,4,5), end # union -@test isequal(union(),Set()) @test isequal(union(Set([1])),Set([1])) s = ∪(Set([1,2]), Set([3,4])) @test isequal(s, Set([1,2,3,4]))