Skip to content

Commit 8ffaf5e

Browse files
committed
reduce_first on the value
1 parent 71b503b commit 8ffaf5e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/fillalgebra.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ end
354354
-(a::AbstractFill) = Fill(-getindex_value(a), size(a))
355355

356356
# special-cased for type-stability, as Ones + Ones is not a Ones
357-
Base.reduce_first(::typeof(+), x::Ones) = convert(Fill, x)
357+
Base.reduce_first(::typeof(+), x::Ones) = Fill(Base.reduce_first(+, getindex_value(x)), axes(x))
358358

359359
function +(a::Zeros{T}, b::Zeros{V}) where {T, V} # for disambiguity
360360
promote_shape(a,b)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ end
826826
@test_throws UndefKeywordError cumsum(Fill(1,1,5))
827827

828828
@test @inferred(sum([Ones(4)])) Fill(1.0, 4)
829+
@test @inferred(sum([Trues(4)])) Fill(1, 4)
829830

830831
@testset "infinite arrays" begin
831832
r = InfiniteArrays.OneToInf()

0 commit comments

Comments
 (0)