@@ -320,6 +320,8 @@ _empty_reduce_error() = throw(ArgumentError("reducing over an empty collection i
320320_empty_reduce_error (@nospecialize (f), @nospecialize (T:: Type )) = throw (ArgumentError ("""
321321 reducing with $f over an empty collection of element type $T is not allowed.
322322 You may be able to prevent this error by supplying an `init` value to the reducer.""" ))
323+ reduce_empty (f, :: Type{Union{}} , splat... ) = _empty_reduce_error (f, Union{})
324+
323325
324326"""
325327 Base.reduce_empty(op, T)
@@ -339,20 +341,15 @@ is generally ambiguous, and especially so when the element type is unknown).
339341
340342As an alternative, consider supplying an `init` value to the reducer.
341343"""
342- reduce_empty (:: typeof (+ ), :: Type{Union{}} ) = _empty_reduce_error (+ , Union{})
343344reduce_empty (:: typeof (+ ), :: Type{T} ) where {T} = zero (T)
344345reduce_empty (:: typeof (+ ), :: Type{Bool} ) = zero (Int)
345- reduce_empty (:: typeof (* ), :: Type{Union{}} ) = _empty_reduce_error (* , Union{})
346346reduce_empty (:: typeof (* ), :: Type{T} ) where {T} = one (T)
347347reduce_empty (:: typeof (* ), :: Type{<:AbstractChar} ) = " "
348348reduce_empty (:: typeof (& ), :: Type{Bool} ) = true
349349reduce_empty (:: typeof (| ), :: Type{Bool} ) = false
350-
351- reduce_empty (:: typeof (add_sum), :: Type{Union{}} ) = _empty_reduce_error (add_sum, Union{})
352350reduce_empty (:: typeof (add_sum), :: Type{T} ) where {T} = reduce_empty (+ , T)
353351reduce_empty (:: typeof (add_sum), :: Type{T} ) where {T<: SmallSigned } = zero (Int)
354352reduce_empty (:: typeof (add_sum), :: Type{T} ) where {T<: SmallUnsigned } = zero (UInt)
355- reduce_empty (:: typeof (mul_prod), :: Type{Union{}} ) = _empty_reduce_error (mul_prod, Union{})
356353reduce_empty (:: typeof (mul_prod), :: Type{T} ) where {T} = reduce_empty (* , T)
357354reduce_empty (:: typeof (mul_prod), :: Type{T} ) where {T<: SmallSigned } = one (Int)
358355reduce_empty (:: typeof (mul_prod), :: Type{T} ) where {T<: SmallUnsigned } = one (UInt)
0 commit comments