Skip to content

BoundsError may be made eachindex aware? #822

Description

@jishnub

This is an optimistic feature request, and I'm unsure if this is possible.

julia> @report_call mode=:sound fill(3, 3)
═════ 2 possible errors found ═════
┌ fill(v::Int64, dims::Int64) @ Base ./array.jl:540
│┌ fill(v::Int64, dims::Tuple{Int64}) @ Base ./array.jl:542
││┌ Vector{Int64}(::UndefInitializer, d::Tuple{Int64}) @ Core ./boot.jl:660
│││┌ Vector{Int64}(::UndefInitializer, m::Int64) @ Core ./boot.jl:647
││││┌ Memory{Int64}(::UndefInitializer, m::Int64) @ Core ./boot.jl:588
│││││ this builtin function call may throw: Core.memorynew(self::Type{Memory{Int64}}, m::Int64)
││││└────────────────────
││┌ fill!(dest::Vector{Int64}, x::Int64) @ Base ./array.jl:329
│││┌ _fill!(dest::Vector{Int64}, x::Int64) @ Base ./array.jl:333
││││┌ setindex!(A::Vector{Int64}, x::Int64, i::Int64) @ Base ./array.jl:986
│││││┌ _setindex!(A::Vector{Int64}, x::Int64, i::Int64) @ Base ./array.jl:990
││││││┌ throw_boundserror(A::Vector{Int64}, I::Tuple{Int64}) @ Base ./essentials.jl:15
│││││││ may throw: throw(BoundsError(A::Vector{Int64}, I::Tuple{Int64})::BoundsError)
││││││└────────────────────

The BoundsError would never be triggered here, as the indices are always within bounds (the loop is over eachindex). It might be helpful to detect such cases and filter these out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions