Skip to content

eltype of BroadcastQuasiArray sometimes falls back to Any #33

@jagot

Description

@jagot

When I want a BroadcastQuasiArray corresponding to a constant function, I do

julia> x = Inclusion(0.0..1.0)
Inclusion(0.0..1.0)

julia> (x -> 1).(x)
QuasiArrays.BroadcastQuasiArray{Int64,1,var"#319#320",Tuple{Inclusion{Float64,Interval{:closed,:closed,Float64}}}}(var"#319#320"(), (Inclusion(0.0..1.0),))

which rightly has an eltype of Int. Likewise, if I explicitly state another type, it also works:

julia> (x -> one(ComplexF64)).(x)
QuasiArrays.BroadcastQuasiArray{Complex{Float64},1,var"#317#318",Tuple{Inclusion{Float64,Interval{:closed,:closed,Float64}}}}(var"#317#318"(), (Inclusion(0.0..1.0),))

However, if the type happens to be stored in a variable, I get Any back:

julia> T = ComplexF64
Complex{Float64}

julia> (x -> one(T)).(x)
QuasiArrays.BroadcastQuasiArray{Any,1,var"#321#322",Tuple{Inclusion{Float64,Interval{:closed,:closed,Float64}}}}(var"#321#322"(), (Inclusion(0.0..1.0),))

Is this easily fixable, or is there a different syntax I should use to avoid type inference ambiguities?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions