Skip to content

Commit 7572e07

Browse files
marius311c42f
andcommitted
Fix broadcasts with only adjoint/transpose static vectors (#704)
Co-authored-by: Chris Foster <chris42f@gmail.com>
1 parent 010397b commit 7572e07

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/broadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ scalar_getindex(x) = x
9797
scalar_getindex(x::Ref) = x[]
9898

9999
@generated function _broadcast(f, ::Size{newsize}, s::Tuple{Vararg{Size}}, a...) where newsize
100-
first_staticarray = a[findfirst(ai -> ai <: StaticArray, a)]
100+
first_staticarray = a[findfirst(ai -> ai <: Union{StaticArray, Transpose{<:Any, <:StaticArray}, Adjoint{<:Any, <:StaticArray}}, a)]
101101

102102
if prod(newsize) == 0
103103
# Use inference to get eltype in empty case (see also comments in _map)

test/broadcast.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ end
115115
# Issue 382: infinite recursion in Base.Broadcast.broadcast_indices with Adjoint
116116
@test @inferred(SVector(1,1)' .+ [1, 1]) == [2 2; 2 2]
117117
@test @inferred(transpose(SVector(1,1)) .+ [1, 1]) == [2 2; 2 2]
118+
119+
# Issue 704: broadcast with adjoint wrapped static arrays
120+
@test @inferred(v1' .+ v2') === SA[2 6]
118121
end
119122

120123
@testset "StaticVector with Scalar" begin

0 commit comments

Comments
 (0)