Fused broadcast cannot guess eltype

x = sprand(10,10,0.1)
z = Float64.(abs.(x))

gives

MethodError: no method matching zero(::Type{Any})
Closest candidates are:
  zero(::Type{Union{Missing, T}}) where T at missing.jl:105
  zero(!Matched::Union{Type{P}, P}) where P<:Dates.Period at /home/ab/src/julia/build1.6/usr/share/julia/stdlib/v1.6/Dates/src/periods.jl:53
  zero(!Matched::T) where T<:Dates.TimeType at /home/ab/src/julia/build1.6/usr/share/julia/stdlib/v1.6/Dates/src/types.jl:423
  ...

The problem seems to be that the fused broadcast cannot guess the eltype Float64 and assigns Any. In contrast,

y = abs.(x)
z = Float64.(y)

works. Is this known?

I think this may be

1 Like