Skip to content

Should broadcast extrude to match length 0 dimensions #32663

@mbauman

Description

@mbauman

Brought up by the ever vigilant @bkamins, we currently support broadcast in some seemingly surprising cases:

julia> rand(5, 0, 5) .+ (1:5)
5×0×5 Array{Float64,3}

julia> rand(5, 0, 5) .+ 1
5×0×5 Array{Float64,3}

julia> rand(5, 0, 5) .+ (1:5)
5×0×5 Array{Float64,3}

julia> rand(5, 0, 5) .+ ones(5,1,1)
5×0×5 Array{Float64,3}

Perhaps even more surprising is this:

julia> x = []
0-element Array{Any,1}

julia> x .= 1
0-element Array{Any,1}

julia> [] .= [1]
0-element Array{Any,1}

I don't think this is horrible enough to warrant a breaking change before 2.0, but perhaps may be something to consider changing in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breakingThis change will break codebroadcastApplying a function over a collectionneeds decisionA decision on this change is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions