Skip to content

Element-wise call syntax does not always lower to standard broadcast() #19313

@nalimilan

Description

@nalimilan

It appears that some simple uses of the element-wise call syntax .( are not lowered to a standard broadcast call. This is a problem for NullableArray where we would like to overload broadcast to apply lifting semantics (JuliaStats/NullableArrays.jl#166).

For example, the following code doesn't call broadcast(get, X, 0). Therefore it fails since my custom broadcast function has a special behavior for get which doesn't get triggered here.

Why it this the case?

julia> expand(:(get.([Nullable()], 0)))
:($(Expr(:thunk, CodeInfo(:(begin 
        $(Expr(:thunk, CodeInfo(:(begin 
        global ##3#4
        const ##3#4
        $(Expr(:composite_type, Symbol("##3#4"), :((Core.svec)()), :((Core.svec)()), :(Core.Function), :((Core.svec)()), false, 0))
        return
    end))))
        $(Expr(:method, false, :((Core.svec)((Core.svec)(##3#4,Any),(Core.svec)())), CodeInfo(:(begin 
        return get(#temp#,0)
    end)), false))
        #3 = $(Expr(:new, Symbol("##3#4")))
        SSAValue(0) = #3
        SSAValue(1) = (Base.vect)(Nullable())
        return (Base.broadcast)(SSAValue(0),SSAValue(1))
    end)))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionwon't changeIndicates that work won't continue on an issue or pull request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions