diff --git a/base/traits.jl b/base/traits.jl index b7239230686c8..53ae14b12c61e 100644 --- a/base/traits.jl +++ b/base/traits.jl @@ -11,6 +11,7 @@ OrderStyle(::Type{<:Real}) = Ordered() OrderStyle(::Type{<:AbstractString}) = Ordered() OrderStyle(::Type{Symbol}) = Ordered() OrderStyle(::Type{<:Any}) = Unordered() +OrderStyle(::Type{Union{}}) = Ordered() # trait for objects that support arithmetic abstract type ArithmeticStyle end diff --git a/test/sets.jl b/test/sets.jl index 2f08ecb210cbb..b090a3d7097fa 100644 --- a/test/sets.jl +++ b/test/sets.jl @@ -447,6 +447,9 @@ end @test @inferred(unique!(iseven, [2, 3, 5, 7, 9])) == [2, 3] @test @inferred(unique!(x -> x % 2 == 0 ? :even : :odd, [1, 2, 3, 4, 2, 2, 1])) == [1, 2] @test @inferred(unique!(x -> x % 2 == 0 ? :even : "odd", [1, 2, 3, 4, 2, 2, 1]; seen=Set{Union{Symbol,String}}())) == [1, 2] + + @test isempty(unique!(Union{}[])) + @test eltype(unique!([i for i in ["1"] if i isa Int])) <: Union{} end @testset "allunique" begin