Skip to content

Bug in broadcast! involving nothing #26097

@tkoolen

Description

@tkoolen

This is fixed by #25377, but if that doesn't make it into 1.0, this is just a reminder to fix the old code.

From #25377 (comment):

julia> X = Any[1,2]
2-element Array{Any,1}:
 1
 2

julia> X .= missing
2-element Array{Any,1}:
 missing
 missing

julia> X .= nothing
ERROR: MethodError: no method matching _broadcast!(::typeof(identity), ::Array{Any,1})
Closest candidates are:
  _broadcast!(::Any, ::AbstractArray, ::K, ::ID, ::AT, ::BT, ::Val{N}, ::Any) where {K, ID, AT, BT, N} at broadcast.jl:377
  _broadcast!(::Any, ::AbstractArray, ::K, ::ID, ::AT, ::Val{nargs}, ::Any, ::Any, ::Any) where {K, ID, AT, nargs} at broadcast.jl:489
  _broadcast!(::Any, ::Any, ::Any, ::Any...) where N at broadcast.jl:477
  ...
Stacktrace:
 [1] broadcast!(::Function, ::Array{Any,1}, ::Nothing) at ./broadcast.jl:455
 [2] top-level scope

and from #24992 (comment):

I note that now I can't use nothing as the first input for broadcast / broadcast! as a scalar value. For instance I can do tuple.([1,2,3], nothing) but I can't do tuple.(nothing, [1,2,3]). This strikes me as odd.

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionbugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions