Skip to content

Constrain the types dispatched on in Base functions like fill, ones, zeros, trues, falses #117

Open
@jishnub

Description

@jishnub

Currently the function signature for fill is

Base.fill(x, inds::Tuple{UnitRange,Vararg{UnitRange}}) =
fill!(OffsetArray{typeof(x)}(undef, inds), x)

However the function clearly only works with integral values, as the OffsetArray constructor only accepts Ints. Something like this will fail:

julia> fill(3.0,UnitRange(3.0,5.0))
ERROR: MethodError: no method matching OffsetArray(::Array{Float64,1}, ::Tuple{Float64})

Should the types dispatched upon be constrained to UnitRange{<:Integer}? This will also allow other packages to define these methods for various other UnitRange types.

The same for other functions like zeros, ones, trues, falses.

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