@@ -316,10 +316,11 @@ pairwise_blocksize(::typeof(abs2), ::typeof(+)) = 4096
316316
317317
318318# handling empty arrays
319- _empty_reduce_error () = throw (ArgumentError (" reducing over an empty collection is not allowed" ))
320- _empty_reduce_error (@nospecialize (f), @nospecialize (T:: Type )) = throw (ArgumentError ("""
321- reducing with $f over an empty collection of element type $T is not allowed.
322- You may be able to prevent this error by supplying an `init` value to the reducer.""" ))
319+ _empty_reduce_error () = throw (ArgumentError (" reducing over an empty collection is not allowed; consider supplying `init` to the reducer" ))
320+ reduce_empty (f, T) = _empty_reduce_error ()
321+ mapreduce_empty (f, op, T) = _empty_reduce_error ()
322+ reduce_empty (f, :: Type{Union{}} , splat... ) = _empty_reduce_error ()
323+ mapreduce_empty (f, op, :: Type{Union{}} , splat... ) = _empty_reduce_error ()
323324
324325"""
325326 Base.reduce_empty(op, T)
@@ -339,20 +340,16 @@ is generally ambiguous, and especially so when the element type is unknown).
339340
340341As an alternative, consider supplying an `init` value to the reducer.
341342"""
342- reduce_empty (:: typeof (+ ), :: Type{Union{}} ) = _empty_reduce_error (+ , Union{})
343343reduce_empty (:: typeof (+ ), :: Type{T} ) where {T} = zero (T)
344344reduce_empty (:: typeof (+ ), :: Type{Bool} ) = zero (Int)
345- reduce_empty (:: typeof (* ), :: Type{Union{}} ) = _empty_reduce_error (* , Union{})
346345reduce_empty (:: typeof (* ), :: Type{T} ) where {T} = one (T)
347346reduce_empty (:: typeof (* ), :: Type{<:AbstractChar} ) = " "
348347reduce_empty (:: typeof (& ), :: Type{Bool} ) = true
349348reduce_empty (:: typeof (| ), :: Type{Bool} ) = false
350349
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)
@@ -753,7 +750,7 @@ julia> maximum([1,2,3])
7537503
754751
755752julia> maximum(())
756- ERROR: MethodError : reducing over an empty collection is not allowed; consider supplying `init` to the reducer
753+ ERROR: ArgumentError : reducing over an empty collection is not allowed; consider supplying `init` to the reducer
757754Stacktrace:
758755[...]
759756
@@ -785,7 +782,7 @@ julia> minimum([1,2,3])
7857821
786783
787784julia> minimum([])
788- ERROR: MethodError : reducing over an empty collection is not allowed; consider supplying `init` to the reducer
785+ ERROR: ArgumentError : reducing over an empty collection is not allowed; consider supplying `init` to the reducer
789786Stacktrace:
790787[...]
791788
0 commit comments