diff --git a/base/broadcast.jl b/base/broadcast.jl index 3e826c5fc7fb3..755cc3d0a8401 100644 --- a/base/broadcast.jl +++ b/base/broadcast.jl @@ -608,6 +608,7 @@ broadcastable(x::Union{AbstractArray,Number,Ref,Tuple,Broadcasted}) = x # Default to collecting iterables — which will error for non-iterables broadcastable(x) = collect(x) broadcastable(::Union{AbstractDict, NamedTuple}) = throw(ArgumentError("broadcasting over dictionaries and `NamedTuple`s is reserved")) +broadcastable(::AbstractSet) = throw(ArgumentError("broadcasting over sets is not defined as their order is not defined")) ## Computation of inferred result type, for empty and concretely inferred cases only _broadcast_getindex_eltype(bc::Broadcasted) = Base._return_type(bc.f, eltypes(bc.args)) diff --git a/test/broadcast.jl b/test/broadcast.jl index 8225f873952f0..aaab3b61c99a3 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -599,8 +599,8 @@ end @test broadcast(identity, Iterators.filter(iseven, 1:10)) == 2:2:10 d = Dict([1,2] => 1.1, [3,2] => 0.1) - @test length.(keys(d)) == [2,2] - @test Set(exp.(Set([1,2,3]))) == Set(exp.([1,2,3])) + @test_broken length.(keys(d)) == [2,2] # Issue #20678 + @test_throws ArgumentError Set(exp.(Set([1,2,3]))) == Set(exp.([1,2,3])) end # Test that broadcasting identity where the input and output Array shapes do not match