Skip to content

Commit 84ae7a2

Browse files
stevengjjohanmon
authored andcommitted
support Ref in has_fast_linear_indexing (JuliaLang#41072)
1 parent 05eff25 commit 84ae7a2

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

base/reducedim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ end
193193

194194
has_fast_linear_indexing(a::AbstractArrayOrBroadcasted) = false
195195
has_fast_linear_indexing(a::Array) = true
196-
has_fast_linear_indexing(::Number) = true # for Broadcasted
196+
has_fast_linear_indexing(::Union{Number,Ref,AbstractChar}) = true # 0d objects, for Broadcasted
197197
has_fast_linear_indexing(bc::Broadcast.Broadcasted) =
198198
all(has_fast_linear_indexing, bc.args)
199199

test/broadcast.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,12 @@ end
914914
# hit the `foldl` branch:
915915
@test IndexStyle(bcraw) == IndexCartesian()
916916
@test reduce(paren, bcraw) == foldl(paren, xs)
917+
918+
# issue #41055
919+
bc = Broadcast.instantiate(Broadcast.broadcasted(Base.literal_pow, Ref(^), [1,2], Ref(Val(2))))
920+
@test sum(bc, dims=1, init=0) == [5]
921+
bc = Broadcast.instantiate(Broadcast.broadcasted(*, ['a','b'], 'c'))
922+
@test prod(bc, dims=1, init="") == ["acbc"]
917923
end
918924

919925
# treat Pair as scalar:

0 commit comments

Comments
 (0)