diff --git a/base/tuple.jl b/base/tuple.jl index ab03aabf73022c..902ff184d71723 100644 --- a/base/tuple.jl +++ b/base/tuple.jl @@ -384,6 +384,13 @@ end convert(::Type{Tuple}, tt::TupleLL) = map(identity, tt) (::Type{Tuple})(tt::TupleLL) = convert(Tuple, tt) +any(f::Function, tt::TupleLL{Nothing, Nothing}) = false +any(f::Function, tt::TupleLL{<:Any, Nothing}) = f(tt.head) +any(f::Function, tt::TupleLL) = f(tt.head) || any(f, tt.rest) + +all(f::Function, tt::TupleLL{Nothing, Nothing}) = true +all(f::Function, tt::TupleLL{<:Any, Nothing}) = f(tt.head) +all(f::Function, tt::TupleLL) = f(tt.head) && all(f, tt.rest) start(tt::TupleLL) = tt next(::TupleLL, tt::TupleLL) = (tt.head, tt.rest) diff --git a/test/broadcast.jl b/test/broadcast.jl index 2715155c8afbe3..be23480dfb1179 100644 --- a/test/broadcast.jl +++ b/test/broadcast.jl @@ -626,3 +626,27 @@ let x = [[1, 4], [2, 5], [3, 6]] z .= .+(x..., .*(x..., x...)..., x[1]..., x[2]..., x[3]...) @test z == Float64[14463, 14472] end + +# Issue #21094 +@generated function foo21094(out, x) + quote + out .= x .+ x + end +end +@test foo21094([0.0], [1.0]) == [2.0] + +# Issue #22053 +struct T22053 + t +end +Broadcast.BroadcastStyle(::Type{T22053}) = Broadcast.Style{T22053}() +Broadcast.broadcast_indices(::Broadcast.Style{T22053}, ::T22053) = () +function Base.copy(bc::Broadcast.Broadcasted{Broadcast.Style{T22053}}) + all(x->isa(x, T22053), bc.args) && return 1 + return 0 +end +Base.:*(::T22053, ::T22053) = 2 +let x = T22053(1) + @test x*x == 2 + @test x.*x == 1 +end